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

Vite socket.io connection websocket first instead of polling? #1

Open
holygekko opened this issue Sep 14, 2021 · 1 comment
Open

Vite socket.io connection websocket first instead of polling? #1

holygekko opened this issue Sep 14, 2021 · 1 comment

Comments

@holygekko
Copy link

I see that when you create a new socket connection you specify to try a websocket first (default is polling first)

socket = io("http://localhost:8081",{transports:["websocket", "polling"]});

I'm currently also working on a project with Vite and Socket.io and I can only make it work in this way (websocket first), polling doesn't work when I run my project with npm run dev.

However if I build my project (with polling first) and deploy than it does work!

I was wondering if you had the same problems and perhaps this is a subtle bug with combining Vite and Socket.io.

@holygekko
Copy link
Author

Found this:
vitejs/vite#4798

Seems to be a bug with Vite and Socket.io-client 4.2.x
I've installed socket.io-client 4.1.3 and polling works as first option :)

I think this is better as there is no fallback from the websocket first approach. It just fails, this way we use polling first and upgrade to websocket. If there's a problem we revert back to polling.

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