I have a problem with socket.io not accepting connections.
I have setup my ERPNext manually in a VPS, Almost everything works well except for socket.io which gives 502 error in the browser network tab like this:
GET /socket.io/?EIO=3&transport=polling&t=NrPeAQm HTTP/3
Host: example.com
and the response is like:
HTTP/3 502 Bad Gateway
content-type: text/html; charset=UTF-8
server: cloudflare
Here’s an example of repetitive error message in /var/logs/nginx/error.log:
Trying restarting the VPS. I know every time I install ERPNext on a new server socketio is always giving me issues. After trying a new config then running sudo reboot It magically worked for me.
It may help to describe the manual setup that was used to install. Operating environment, versions of apps etc and steps taken to install. That may provide clues.
Thanks so much @revant_one , POST requests are working now but not GET unfortunately, It doesn’t even get initialized by the browser idk why!! Anyway, I’m happy about the current setup and I’ve already documented all of my manual setup instructions from the beginning, and I’m going to post them here in the forum.
Answer by @revant_one is the solution. However, additionally make sure that:
supervisor is reloaded with new config file – service supervisor restart bench restart
in my case even after the config file was showing the [program:frappe-bench-node-socketio]
but bench restart was never listing the frappe-bench-web:frappe-bench-node-socketio: (for any status, as revant_one was also wondering!), this pointed me to realize supervisorctl is not reading the updated config file.
@revant_one ideally isn’t bench restart be doing service supervisor restart internally? I know this could spoil the redis cache. But no point restarting bench with old config. Or alternatively there could be a switch say bench restart --refresh-supervisor-config.
The 502 error isn’t because Socket.IO is off. It happens because Nginx or Cloudflare can’t connect to 127.0.0.1:9000. Fix the Nginx proxy and make sure the port is listening, and it will work.
Hello sir,
I am new to frappe configuration, I am not finding where to change the configurations… I am using Cloudflare Zero-Trust tunnel and when I try to access the health check I notice the socket.io ping has failed, but not when I access from within the server.
Would you mind to let me know where and what I should change in the nginx conf in order to allow the socket.io traff see through the cloudflared tunnel ?
best regards,
Hello, am experiencing the same thing, have done all above but can’t get it working, does anyone know proper way of setting it up since that bench setup socketio is [DEPRECATED]
Socket.io has always been a bit tricky for me to set up as well. Each environment tends to behave slightly differently, and even small differences can cause it to break.
I ended up spending some time digging into how it actually works to better understand and troubleshoot these issues.
I’ve put together a detailed write-up here in case it helps:
Thank you for posting the blog with the detailed tests.
I do not use docker. So I was wondering if you can share what the nginx config for network alias that was done to get it to work.
Here is the paragraph that mentioned it.
“The fix was adding a network alias to the Nginx container so that internal requests to the domain were served directly within the Docker network without going through the external redirect. This ensured cookies were preserved and the correct user was identified.”