Describe the bug
After the first message is received, it no longer receives messages. Very rarely I dont receive any message at all. I only seem to experience this in the development mode (npm run dev of Next.js 14)
I have a very simple socket IO setup example below. Basically a simple page in the /app dir of Next.js and the API endpoint for the socket server creation in the old /pages dir. After the websocket server is created, it emits a message to the hello channel each second. When the page is loaded I only receive the message once. Very rarely, it works as intended. 90% of the time I only receive the first message.
I also noticed that it does some polling once a minute or so. I'm not sure why it does that, as the connection seems to be established and upgraded to websocket. Here is a screenshot from the network tab: Imgur
This is how the developer console looks like: Imgur
No errors server side.
Additionally, seems to fix itself after like 10 minutes, the messages start coming again.
Describe the bug After the first message is received, it no longer receives messages. Very rarely I dont receive any message at all. I only seem to experience this in the development mode (npm run dev of Next.js 14)
I have a very simple socket IO setup example below. Basically a simple page in the /app dir of Next.js and the API endpoint for the socket server creation in the old /pages dir. After the websocket server is created, it emits a message to the
hello
channel each second. When the page is loaded I only receive the message once. Very rarely, it works as intended. 90% of the time I only receive the first message.I also noticed that it does some polling once a minute or so. I'm not sure why it does that, as the connection seems to be established and upgraded to websocket. Here is a screenshot from the network tab: Imgur This is how the developer console looks like: Imgur
No errors server side. Additionally, seems to fix itself after like 10 minutes, the messages start coming again.
To Reproduce You can find the example page (page.tsx), which is located in Next.js /app dir, and the API endpoint for the socket server creation, which is located in the old /pages/api dir, at this gist: https://gist.github.com/Angeschossen/84e1b50d93b5a0c1425eed4776a999d0
Next.js: v. 14.2.5 SocketIO and Client: 4.7.5
Expected behavior Each message should be received. As you can see the API endpoint emits a message every second.
Platform:
Additional context I have react strict mode disabled.