ngauthier / tubesock

Websocket interface on Rack Hijack w/ Rails support
MIT License
620 stars 43 forks source link

getting timeout issues #9

Closed patcito closed 11 years ago

patcito commented 11 years ago

If I let tubesock run idle after a while I get this error which crashes the app:

Exiting
/usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.1.3/lib/tubesock.rb:75:in recvfrom': Connection timed out - recvfrom(2) (Errno::ETIMEDOUT) from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.1.3/lib/tubesock.rb:75:ineach_frame' from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.1.3/lib/tubesock.rb:63:in `block in listen'

ngauthier commented 11 years ago

Hi,

Please update tubesock to the latest version, 0.2.2. I'm going to close this issue. If you still have a problem, reopen it.

Thanks!

patcito commented 11 years ago

Ok thanks, will give it a try.

patcito commented 11 years ago

Ok, I tried and I'm still getting the same error and crash with 0.2.2:

Exiting /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:93:in recvfrom': Connection timed out - recvfrom(2) (Errno::ETIMEDOUT) from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:93:ineach_frame' from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:63:in `block in listen'

ngauthier commented 11 years ago

Hmm.

Could you please describe when this is happening? For example, the first time you send data, or after X seconds?

Also, recvfrom is part of Ruby, and I noticed you're on an rc of ruby 2. You could try updating to the latest patch level of ruby.

Unfortunately, I'm driving all day today and I'm without internet and on vacation for a few days, so I won't be able to help you until next week. Sorry.

Nick On Aug 14, 2013 6:34 AM, "Patrick Aljord" notifications@github.com wrote:

Ok, I tried and I'm still getting the same error and crash with 0.2.2:

Exiting /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:93:in recvfrom': Connection timed out - recvfrom(2) (Errno::ETIMEDOUT) from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:93:in each_frame' from /usr/local/rvm/gems/ruby-2.0.0-rc1/gems/tubesock-0.2.2/lib/tubesock.rb:63:in `block in listen'

— Reply to this email directly or view it on GitHubhttps://github.com/ngauthier/tubesock/issues/9#issuecomment-22626949 .

patcito commented 11 years ago

Hey Nick. So I updated to latest ruby 2 and I still get this error. Not sure what's causing this. It happens sometimes when the server is idle, sometime it happens when I send a message. It's pretty random.

/usr/local/rvm/gems/ruby-2.0.0-p247/gems/tubesock-0.2.2/lib/tubesock.rb:93:in recvfrom': Connection timed out - recvfrom( 2) (Errno::ETIMEDOUT) from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/tubesock-0.2.2/lib/tubesock.rb:93:ineach_frame' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/tubesock-0.2.2/lib/tubesock.rb:63:in `block in listen'

patcito commented 11 years ago

Ok, I was able to reproduce and fixed it in my code at least. So I was bypassing redis in the onopen callback like that:

tubesock.onopen do   
  tubesock.send_data config.to_json
end

Turns out that config took a while when there's no cache and if I lost my internet connection during the onopen call or just refresh the browser during the onopen call, it would crash tubesock with the error I already pasted previously. Modifying the code this way to always use redis seems to have fixed it so far:

tubesock.onopen do   
  Redis.new.publish("messages", config.to_json)
end

And then Redis calls the the tubesock.send_data with no issue even if I refresh during the call.

Hope this helps and thanks a lot!

ngauthier commented 11 years ago

Hmm, not really sure why that would make a difference. Sorry!