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
Option to disable pendingSend globally #13
Comments
You can increase the size of the send queue by setting If the send queue is disabled and you try to send on a disconnected socket, this sounds like it should cause an exception anyway. I could see adding an option to silently ignore sent messages on disconnected sockets, but this sounds a little sketchy also. Thoughts? |
Sorry didn't mean to close. |
I believe that ignoring seems to be better in this case, this would serve as a second barrier if the software that is calling the module fails in some way to check at that instant that the socket is disconnected, an example is what occurs in my game, there is an exchange of messages between the server and clients, massively including with Broadcast (sends to several of a particular group / room) In case leaving this as optional, without affecting the other users of the module who may use pendingSend. Another point to take into consideration, is that even if it increased the limit of the MAX_SEND_QUEUE_SIZE, there would still be a memory expenditure to allocate in the array these requests, depending mainly on the size that are sent in each request or am I wrong? |
Is your issue happening on the server side or client side? If on the server side, you may need to listen for socket disconnection, so that you don't write to disconnected sockets. Doing so is an error, I think. If on the client side, it depends on how you want re-connection logic to work. Most users will want to send all messages that got queued up while disconnected. If you instead want to drop these, we can probably modify this lib a bit to make that work. To answer your question, if you increase Sorry that was a slightly rushed explanation. Does that make sense? |
thanks for the reply, yes it is on the server side and there is also a logic to remove from the list when they are disconnected, but for some strange reason even so still keeps some broken connections without sending in disconnect event (there's no auto reconnect in client side) |
I think I understand. So, you try to send data to a "broken" socket that subsequently "disconnects?" Then, this exception propagates through the server, ultimately crashing it? |
Exactly, I believe that some glitch or momentary connection loss causes this effect. I use it the same way as in the pull request and don't have these problems anymore. |
OK. I think we may just want to add an option to silently ignore send errors. This is not really a send queue issue AFAIK. In other words, instead of Would you be willing to share the error stack trace (or a portion of it) here? Is it easy to replicate? |
Yes, the problem is not related to queueing, it would be more of an option to disable memory consumption and avoid server restart. I think it could work by splitting it into two options
Users would have between these two options to better choose what they want And about reproducing the problem, it is not so simple in tests with few people, it has only occurred when I launch in production when there are more than 70 simultaneous players and have a good amount of time online. |
Makes sense. Thanks, @GustavoMorais. I'll implement something and will keep you posted. |
Hey - is there any update on a solution to this? |
@Dussed I made a fork where there is this implementation (I use it on my production server) |
@GustavoMorais thank you very much! |
@GustavoMorais - After thinking about this a bit more, I don't think there is anything to do here. You can disable the send queue by setting It's a good idea to catch exceptions when calling the Please let me know your thoughts, but I'm going to close this for now. |
It would be good having an option to disable _pendingSend
I have a game that uses this library and sometimes occurs of some connections fail and throw the error "WebSocket is not connected and send queue is full" and cause restart at my server, currently for me to deal with this I have to edit the module manually on server and comment on the function "send(data, ignoreMaxQueueSize)"
Pull Request:
#14
The text was updated successfully, but these errors were encountered: