Socket.io not working on production sites

See original GitHub issue

Description of the issue

In the recent update to Frappe v14, socket.io stopped working - gives a 502 Bad Gateway error.

Supervisor status gives the following:

frappe-bench-redis:frappe-bench-redis-cache                 RUNNING   pid 17564, uptime 0:10:33
frappe-bench-redis:frappe-bench-redis-queue                 RUNNING   pid 17565, uptime 0:10:33
frappe-bench-redis:frappe-bench-redis-socketio              RUNNING   pid 17566, uptime 0:10:33
frappe-bench-web:frappe-bench-frappe-web                    RUNNING   pid 17567, uptime 0:10:33
frappe-bench-web:frappe-bench-node-socketio                 FATAL     Exited too quickly (process log may have details)
frappe-bench-workers:frappe-bench-frappe-default-worker-0   RUNNING   pid 17574, uptime 0:10:33
frappe-bench-workers:frappe-bench-frappe-long-worker-0      RUNNING   pid 17576, uptime 0:10:33
frappe-bench-workers:frappe-bench-frappe-schedule           RUNNING   pid 17573, uptime 0:10:33
frappe-bench-workers:frappe-bench-frappe-short-worker-0     RUNNING   pid 17575, uptime 0:10:33

Restarting supervisor does not resolve the issue. It gives a SPAWN error:

frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-redis:frappe-bench-redis-cache: stopped
frappe-bench-redis:frappe-bench-redis-socketio: stopped
frappe-bench-redis:frappe-bench-redis-queue: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-redis:frappe-bench-redis-cache: started
frappe-bench-redis:frappe-bench-redis-queue: started
frappe-bench-redis:frappe-bench-redis-socketio: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)

I checked the node-socketio.error.log file and found this:

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
/home/frappe/frappe-bench/apps/frappe/socketio.js:306
                                args?.callback(err, res);`

The method can_subscribe_list was added in the recent update and it has optional chaining on line 306: args?.callback() - which might be causing the error?

Additional information

Frappe version: 14.17.0 Bench version: 5.15.1

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nikkothari22commented, Dec 1, 2022

Hey @ankush - the node version is v16.15.0

0reactions
bibinqcscommented, Dec 9, 2022

ok I will try now and see

Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.io connect failed on production, working in localhost
In your server code please add the following line io.set('origins', '*:*');. So your code will be //socket io config const server ...
Read more >
Troubleshooting connection issues | Socket.IO
First and foremost, please note that disconnections are common and expected, even on a stable Internet connection:
Read more >
Socket IO not working in Production Ubuntu 18.04 - Deployment
I have setup ERPNext with easy install script. Activated dns multi tenant setup with letsencrypt. erpnext 12.8.0 frappe 12.5.1.
Read more >
Socket.io works only on localhost - Laracasts
I got node.js running, reddis working and port 3000 is listening. I can get console messages on command line. Problem occurs when i...
Read more >
Everything you need to know about Socket.IO - Ably Realtime
Problems come when working at scale. Say, for example, you want to build a CRM-like app that enables communications between businesses. Socket.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found