Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用useWebSocket会一直开启关闭重启 #3936

Open
7 tasks done
Anima-No opened this issue Apr 26, 2024 · 1 comment
Open
7 tasks done

使用useWebSocket会一直开启关闭重启 #3936

Anima-No opened this issue Apr 26, 2024 · 1 comment

Comments

@Anima-No
Copy link

Describe the bug

使用的版本为: "@vueuse/core": "^10.9.0"
这是一段运行的代码
`

const state = reactive({
server: 'ws://124.222.224.186:8800',
retryTimeout: 3000,
sendValue: '',
recordList: [],

});

const { status, data, send, close, open } = useWebSocket(state.server, {
heartbeat: {
message: 'ping',
interval: state.retryTimeout
},
autoReconnect: true,
});

watchEffect(() => {
if (data.value) {
state.recordList.push(data.value);
console.log(state.recordList)
}
//会一直开启,关闭,重启
console.log(status.value)
});

如果这个ws无法连接请自行换个可以用的wss
`
由于Reproduction内无法使用ws链接,请自行更换wss链接即可复现

Reproduction

https://stackblitz.com/edit/vitejs-vite-ytf48z?file=package.json,src%2FApp.vue

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vueuse/core: ^10.9.0 => 10.9.0 
    vue: ^3.2.25 => 3.2.31

Used Package Manager

npm

Validations

@Anima-No
Copy link
Author

15:00:53 [vite] hmr update /src/App.vue
App.vue?import&t=1714114853783:30 CONNECTING
client.ts:352 [vite] hot updated: /src/App.vue
App.vue?import&t=1714114853783:30 OPEN
App.vue?import&t=1714114853783:30 CLOSED
App.vue?import&t=1714114853783:30 CONNECTING
App.vue?import&t=1714114853783:30 OPEN
App.vue?import&t=1714114853783:30 CLOSED
App.vue?import&t=1714114853783:30 CONNECTING
App.vue?import&t=1714114853783:30 OPEN
App.vue?import&t=1714114853783:30 CLOSED
App.vue?import&t=1714114853783:30 CONNECTING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant