Skip to content
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

Invalid access of closed uWS.WebSocket/SSLWebSocket. #169

Closed
jsandfordhughes opened this issue Nov 25, 2021 · 5 comments · Fixed by #170
Closed

Invalid access of closed uWS.WebSocket/SSLWebSocket. #169

jsandfordhughes opened this issue Nov 25, 2021 · 5 comments · Fixed by #170
Labels
goal:fix Something isn't working

Comments

@jsandfordhughes
Copy link

We have had some issues with the server throwing these exceptions in the CLI from the server it is running from, while these errors were being thrown we had issues with clients not receiving messages.

The client could subscribe to the channel however would not receive any messages while other clients on the same channel would. If the same client joined another channel they would be getting messages. This was completely random on what clients would receive which messages, we have since restarted the pws-server and now cannot replicate the errors again.

Any help would be much appreciated.

(node:3267) UnhandledPromiseRejectionWarning: Error: Invalid access of closed uWS.WebSocket/SSLWebSocket.
at uWS.WebSocket.ws.sendJson (/usr/lib/node_modules/@soketi/pws/dist/ws-handler.js:22:20)
at /usr/lib/node_modules/@soketi/pws/dist/ws-handler.js:44:20
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:3267) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3267) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@rennokki
Copy link
Member

This can happen if the server gets closed and somehow, a nasty message wants to be sent by your user in the server. I think this is a real bug after i checked the code again. I'm working on a fix. 🔧

@rennokki rennokki added the goal:fix Something isn't working label Nov 25, 2021
@jsandfordhughes
Copy link
Author

Great, so would the bug stop messages being sent to users?

@rennokki
Copy link
Member

I assume your server hanged closing and that's why your users could access other channels but not their current ones. I need more info to help you.

  • what OS are you running?
  • is the app deployed as single instance or in horizontal scaling mode?
  • which version of soketi caused this error?

@jsandfordhughes
Copy link
Author

jsandfordhughes commented Nov 26, 2021

  • Ubuntu 20.04.3 LTS
  • Single instance using REDIS for the DB and DynamoDB for App
  • version 0.8

Thanks

Joe

@rennokki
Copy link
Member

The issue is that for some reason, environmentally-based, your server hanged closing. What I'd recommend here, and I'll update docs regarding this thing, you should have a retry policy for sending messages.

I'll have a soft check in the app fixing message sending and communication for pending closing servers so that once the server receives any SIG{INT,TERM,HUP} signal, it will mark the server as pending closing, new clients won't be able to connect to the server, existing clients (while closing) cannot subscribe to new channels in the same server. Client messages and HTTP REST API interaction will still work.

You don't need Redis if you have only one instance running at any time. That's because Redis is used for inter-node comms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:fix Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants