Deploying Next.js 14 with Socket.io on Vercel/Google Cloud Run: Issues with Socket Functionality Not
Answered
Giant panda posted this in #help-forum
Giant pandaOP
Hi
I am currently developing a Next.js 14 application that incorporates Socket.io and "next custom server". The development process was guided by the example provided on the official Socket.io website: https://socket.io/how-to/use-with-nextjs.
While the application functions correctly on my local development server, I encounter issues with the socket functionalities upon deployment; only the Next.js routing and client-side code are working (I suppose it is due to Next Custom Server not supported). I have attempted deployments on both Vercel and Google Cloud Run without success.
Could anyone provide guidance on the appropriate deployment strategies or hosting environments that support "Socket.io/Custom Server" within a Next.js application? Any insights or suggestions you could offer would be greatly appreciated.
Thank you for your time and assistance.
I am currently developing a Next.js 14 application that incorporates Socket.io and "next custom server". The development process was guided by the example provided on the official Socket.io website: https://socket.io/how-to/use-with-nextjs.
While the application functions correctly on my local development server, I encounter issues with the socket functionalities upon deployment; only the Next.js routing and client-side code are working (I suppose it is due to Next Custom Server not supported). I have attempted deployments on both Vercel and Google Cloud Run without success.
Could anyone provide guidance on the appropriate deployment strategies or hosting environments that support "Socket.io/Custom Server" within a Next.js application? Any insights or suggestions you could offer would be greatly appreciated.
Thank you for your time and assistance.
Answered by joulev
dunno about google cloud run, but you cannot host ws on vercel.
you must have a server running 24/7 for ws to work. in other words, rent a virtual private server. like a digitalocean droplet for example.
you must have a server running 24/7 for ws to work. in other words, rent a virtual private server. like a digitalocean droplet for example.
6 Replies
@Giant panda Hi
I am currently developing a Next.js 14 application that incorporates Socket.io and "next custom server". The development process was guided by the example provided on the official Socket.io website: https://socket.io/how-to/use-with-nextjs.
While the application functions correctly on my local development server, I encounter issues with the socket functionalities upon deployment; only the Next.js routing and client-side code are working (I suppose it is due to Next Custom Server not supported). I have attempted deployments on both Vercel and Google Cloud Run without success.
Could anyone provide guidance on the appropriate deployment strategies or hosting environments that support "Socket.io/Custom Server" within a Next.js application? Any insights or suggestions you could offer would be greatly appreciated.
Thank you for your time and assistance.
dunno about google cloud run, but you cannot host ws on vercel.
you must have a server running 24/7 for ws to work. in other words, rent a virtual private server. like a digitalocean droplet for example.
you must have a server running 24/7 for ws to work. in other words, rent a virtual private server. like a digitalocean droplet for example.
Answer
Giant pandaOP
Thank you Joulev.
Is there a way to Dockerize for scalability in the future?
Is there a way to Dockerize for scalability in the future?
well... you just dockerise it? all hosting platforms and server providers should support docker well
Giant pandaOP
Do you have any suggested hosting service?
no, sorry. i have not had to host a ws server before
Giant pandaOP
Thank you so much for your help