Refactor: swap the order to poll and than upgrade to WS
This commit is contained in:
parent
fa9f1fcefc
commit
28207bcd41
1 changed files with 2 additions and 8 deletions
|
|
@ -51,7 +51,7 @@ export const useSocketStore = defineStore('socket', () => {
|
|||
|
||||
const connect = () => {
|
||||
const opts = {
|
||||
transports: ['websocket', 'polling'],
|
||||
transports: ['polling', 'websocket'],
|
||||
withCredentials: true,
|
||||
reconnection: true,
|
||||
reconnectionAttempts: 50,
|
||||
|
|
@ -72,13 +72,7 @@ export const useSocketStore = defineStore('socket', () => {
|
|||
connectionStatus.value = 'connecting';
|
||||
socket.value = io(url, opts)
|
||||
|
||||
on("connect_error", (e: any) => {
|
||||
if (!socket.value) {
|
||||
return;
|
||||
}
|
||||
console.error("Socket connection error:", e);
|
||||
socket.value.io.opts.transports = ["polling", "websocket"];
|
||||
});
|
||||
on("connect_error", (e: any) => console.error("Socket connection error:", e));
|
||||
|
||||
on('connect', () => {
|
||||
isConnected.value = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue