imanel/websocket-rack — Issue #7: EM Eventloop & Websocket-Rack
Author: etm
Created: 2012-01-05 23:56:13+00:00
State: open

I have a server that is running a background thread, that sends events through a websocket to the client. The thread is stopped and started through an ajax call (not through the websocket), the websocket is up the whole time.

Current thin + websocket-rack + eventmachine 0.12.10
* everything works as expected

Current thin + websocket-rack + eventmachine 1.0.0.beta.4
* whenever send is called in the background thread, the sent data is buffered (?) and only is sent to the browser after (a) a timeout of about 30 seconds, or (b) after manually triggering the server (e.g. making calls to different pages of the server or even call wrong locations on the server).

Obviously something with the EM eventloop has changed. Debuging showed that the @socket.send_data (in websocket-rack / lib / rack / websocket / handler / base / connection.rb line 25) is always called correctly (at the right time) and returns immediately just afterwards the data is buffered (?).

Any idea how to best solve this? (e.g. scheduling the next tick in the EM eventloop every time after a send).

cheers. eTM