graphql with subscriptions disconnect
Closed this issue · 5 comments
mabc224 commented
I am using graphql with subscriptions. There many microservices which are connected with gateway. I am facing below error. My gateway server disconnects when react app page is refreshed and it due to subscription socket.
Context
- Moleculer version: 0.14.12
- NodeJS version: 12.18.0
- Operating System: Ubuntu
- Other dependencies
"moleculer-apollo-server": "0.3.3",
"moleculer-web": "0.10.0-beta1",
"nats": "1.0.0",
Current Behavior
Server disconnects upon refreshing page.
/app/node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js:757
websocket.readyState = WebSocket.CLOSING;
^TypeError: Cannot set property 'readyState' of undefined
at Socket.socketOnClose (/app/node_modules/subscriptions-transport-ws/node_modules/ws/lib/websocket.js:757:24)
at emitOne (events.js:121:20)
at Socket.emit (events.js:211:7)
at TCP._handle.close [as _onclose] (net.js:561:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bananarama-gateway@0.0.1 start: `node bin/runner.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bananarama-gateway@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-04-14T17_38_21_963Z-debug.log
Expected Behavior
It should not disconnect.
mabc224 commented
AndreMaz commented
What are the steps to reproduce the error?
mabc224 commented
When page is refreshed, Then this error usually happen.
On my staging servers with little to no load, this error happened time to time in an hour.
On my production servers, this error happened frequently under high load.
And when it happened, the server crashed and got restarted by kubernetes intentionally.
And then all the previously connected clients reconnected at once.