Socket.io connection + Next12 + Vercel
Answered
Cinnamon posted this in #help-forum
CinnamonOP
Hello dear members of this server,
Coming here looking for help to resolve a problem I am having which involves webRTC + Next12 + Socket.io.
I have created a simple project for video calls using PeerJS, which, locally works fine BUT once it is deployed into vercel (under https) for some reason the socket is never connected fails to stablish the connection.
When using
When using
I am running out of ideas, I have changed the transports, the cors, generate custom id, etc, and nothing is working so far.
This is my repo where you can see the code. The only problem (i guess) is inside the
This is the repo I've created where you can see the code
https://gitlab.com/miguel-cuevas/webrtc
Any help will be apreciated ðŸ˜
Coming here looking for help to resolve a problem I am having which involves webRTC + Next12 + Socket.io.
I have created a simple project for video calls using PeerJS, which, locally works fine BUT once it is deployed into vercel (under https) for some reason the socket is never connected fails to stablish the connection.
When using
transport
, I got errors because something about Session ID is not defined, so, it means I need Sticky Sessions, I am not very familiar with this as BE is not my strong skill.When using
websocket
transport, the connection to the socket is never happening. It only receives WebSocket connection to {insert_server_here} failed
.I am running out of ideas, I have changed the transports, the cors, generate custom id, etc, and nothing is working so far.
This is my repo where you can see the code. The only problem (i guess) is inside the
src/pages/api/socketio.ts
or maybe it is something with vercel?This is the repo I've created where you can see the code
https://gitlab.com/miguel-cuevas/webrtc
Any help will be apreciated ðŸ˜
Answered by baked
You can’t deploy websockets to vercel. Websockets require a serverful environment and vercel is entirely serverless
3 Replies
You can’t deploy websockets to vercel. Websockets require a serverful environment and vercel is entirely serverless
Answer
CinnamonOP
Thanks @baked for your answer
Interesting... so that means I cannot use websockets transport option of socket.io, but, what about polling transport? Is the same situation?
If that is the case then I have to find a different way to deploy the project 🤔
Interesting... so that means I cannot use websockets transport option of socket.io, but, what about polling transport? Is the same situation?
If that is the case then I have to find a different way to deploy the project 🤔
The polling transport is also stateful afaik so that also won’t work. You can either deploy somewhere else or decouple the websocket service from your frontend and host those separately