-
Notifications
You must be signed in to change notification settings - Fork 96
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
EM keeps shutdown when server overloads. #125
Comments
Can you add this listener to your socket to see what error it prints when the socket closes? ws.on :error do |error|
# ...
end |
I have added it, waiting for server to overload the client. |
.on :error listener doesn't seem to catch anything, same old messages
|
Normally, the Why are you stopping EventMachine, and why are you wrapping it in your own threads? |
I am working on a project which depends on synchronous code but is using EM and websocket in it. We changed a code a bit, for now we use thread to only start EM so it won't break the main thread. We had some errors in functionality that caused an errors but they were never propagated to EM, because we used own Threads. We rewrote it to use EM.defer, for now it's working but we need to test it more. If there is any "best-way-to" start EM on server start ( like in rack, or cron or something ) so everytime user wants to start its websocket EM will already be running, i am listening. Anyway, thanks for your time. |
Yeah, mixing synchronous code with EM is painful. This package uses this function to start the reactor: https://github.com/faye/faye-websocket-ruby/blob/master/lib/faye/websocket.rb#L39-L42. Don't call that, it's not part of the public API -- write your own version of it. |
Hi there again. We are using this gem to create client, but we can't figure out why client shutdowns EM immediately if server overloads out client with lots of messages. It happens sporadically once a day or two.
We create client as follows:
We need to run client socket in dedicated thread so it won't block anything. Problem starts when server overloads our client with messages, we do not see the messages after overload in ws_logger file, but we have this:
The fact that EM SHUTDOWN HOOK is first and the socket closes with 1006 tells us, something is wrong. Maybe server sents very big bulk of messages client can't process ?
We have to be able to recover from 1006 and restart web-socket to be running again, but with EM being shutdown, recovery code is killed with it and software stops.
I look some info around sockets, maybe we need to set max_length option to client ? But it buggers me that The default value is 2^26 - 1, or 1 byte short of 64 MiB is not enough ?
I do not know is this is relevant, but i even looked at default buffer size in out machine according to this post https://stackoverflow.com/questions/7865069/how-to-find-the-socket-buffer-size-of-linux.
One more thing, can't figure out what is the difference between this gem and websocket-driver-ruby. Isn't the websocket-driver-ruby more suitable for us ?
If you need more info, ask for it.
Thanks in advance.
The text was updated successfully, but these errors were encountered: