-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
[NEXT-1119] Socket.IO Not working anymore from Next.js 13.2.5-canary.27 to latest Next.js 13.4.1 #49334
Comments
Same problem @leerob |
Same here |
Thank you for reporting! The best way to track this is by upvoting the issue versus commenting, unless you can provide additional information or reproductions. Greatly appreciate the assistance with making a minimal reproduction 🙏 |
Pointed these two discussions here:
And this issue: |
It appears that after "13.2.5-canary.26", a trailing slash is appended to the end of the route. Disabling "addTrailingSlash" in the Socket.IO Server constructor resolved this for me on the latest version (13.4.1).
|
i think the problem in your old path path: "/api/my_awesome_socket", |
This worked for me |
Also worked for me on latest 13.4.1, thanks! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
The problem still remains and is about Next.js server ignores listeners to https://codesandbox.io/p/sandbox/busy-euclid-qbvdv8 This project creates an API route (pages/api/proxy.ts) that adds a listener to next.js server listening to In Next.js 13.2.5, it works fine. Both In Next.js 13.4.2, only |
Thank you for explaining, I was also having same problem, when I explained here #49334 (comment) But I was unable to explain with proper context, thank you for this example. |
and do we have a workaround? |
any solutions ? : (using App Router) 'use client' const socket = io('http://localhost:3000'); export default function Page(){ return ( );}; errors : Module not found: Can't resolve 'bufferutil' in ... |
any solution? |
Any solution for pure app dir work? Currently my working approach is api is from pages dir and website is from app dir. |
Module not found: Can't resolve 'bufferutil' in ... npm install bufferutil utf-8-validate |
For those still having issues, I found that removing the "transports" prop in the client worked for me (unless I did something else) |
For those who are having this 404 error, I found that removing not-found.jsx file fixes this. |
Downgraded my NextJS version to 13.2.4 to resolve the issue temporarily. |
@huozhi I just realised that the socket.io is falling back to polling instead of WebSocket. Can you check on this once? Codesandbox testing project - https://codesandbox.io/p/sandbox/nextjs-socketio-forked-7k5px3?file=%2Fpackage.json%3A4%2C21&selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A4%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A4%7D%5D |
I'm meeting this problem too when upgrading Next.js to 13.5.4 Hoping the issue can be resolved soon. |
I'm facing the same issue when upgrading to Next.js 13.5.3. Good luck for the one who will resolve this issue. |
I'm seeing socket.io failing on nextjs 13.5.4. I downgraded to 13.2.4 as was suggested and it works |
tried using 13.5.4 with a custom server, and socket io implementation is stuck on switching protocol |
Where I can deploy this setup NextJS + socketio? |
I am having the same problems even without socket io. I'm using t3-stack with trpc's websocket implementation and the server is getting flooded with upgrade requests that close down with 1006 error immediately after. I believe this is a general websocket problem since other libraries are having the same issue #54589 . |
Same issue. Downgraded to 13.4.12 like @RonaldErnst suggested and it works fine... Hope we can get this resolved quickly. Websockets are completely broken on nextJS, across all libraries. I need to force websocket transport with socket.io to deploy to cloud run. Alternative socket.io transports seem to work but I need websockets... Another temp fix could be deploying WS server to a different port but once again that wouldn't work for people using cloud run etc... |
We are a running the They same issue exists for this use-case and the proxy does not work anymore. |
Issue still persists in Is there a chance to increase priority on this? |
I have same issiue with transport upgrades. It is always working as polling mode. It is never upgrading to websockets... |
Thank you for the patch! |
Still getting |
Same issue still continues @huozhi |
so i use it with graphql + custom express server and it is working in dev and production with 13.5.7-canary.23. // init next app
await nextApp.prepare()
// create express app
const expressApp = express()
const httpServer = createServer(expressApp)
// create the websocket server
const wsServer = new WSServer({
path: '/graphql',
noServer: true
})
const cleanUp = useServer({ schema }, wsServer)
const plugins = [
ApolloServerPluginDrainHttpServer({ httpServer }),
{
async serverWillStart() {
return {
async drainServer() {
await cleanUp.dispose()
}
}
}
}
]
const apolloServer = new ApolloServer<Context>({
csrfPrevention: true,
schema,
plugins
})
await apolloServer.start()
expressApp.use(graphqlUploadExpress()) the important part is not to pass the |
@KillerCodeMonkey that is valuable contribution, thanks! Finally upgraded to |
The fix is landed in 14.0, please upgrade to the latest next.js! 🙏 btw there's no new feature so it should work well like v13 |
I confirm its working perfectly fine with Next.js Latest version (14.0.0), however one must ensure to use Node v18.17.x or higher version, as its a breaking change in Next.js 14 - refer the changelog for Next.js v14 here. Thank a lot @huozhi, @shuding and the Next.js team for resolving this issue. Also I thank you very much @leerob for helping me to create this issue page for the resolution. Lots of ❤️ for the great Next.js Community. |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/nextjs-socketio-u89y82?file=%2Fpackage.json&selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A4%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A4%7D%5D
To Reproduce
Agenda of this project?
The App is have the following things -
Whats the Issue?
Since when this issue is happening?
Do we have an Example project?
Steps to Reproduce
Some References PR for / might this issue have created?
Describe the Bug
Expected Behavior
Which browser are you using? (if relevant)
I am using latest Chrome version, but this has to do more with Next.js Core server. It has nothing to do with any browsers.
How are you deploying your application? (if relevant)
Using Docker, but this is irrelevant too, as in localhost also, there is this issue.
NEXT-1119
The text was updated successfully, but these errors were encountered: