celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

help with server-side disconnects in slack-ruby-client #187

Open dblock opened 6 years ago

dblock commented 6 years ago

Coming from https://github.com/slack-ruby/slack-ruby-client/issues/208. The celluloid-io code we have isn't detecting server-side disconnects occasionally. We could really use some professional help, we're likely not using celluloid-io correctly in https://github.com/slack-ruby/slack-ruby-client/blob/master/lib/slack/real_time/concurrency/celluloid.rb#L31

tarcieri commented 6 years ago

@dblock Celluloid::IO is effectively unmaintained. I would suggest switching to async:

https://github.com/socketry/async

dblock commented 6 years ago

I opened https://github.com/slack-ruby/slack-ruby-client/issues/210 maybe someone will contribute. Still, celluloid serves us well rn and I'd like to fix the issue as well.

ioquatix commented 6 years ago

Here is (roughly) what we use.

https://gist.github.com/ioquatix/c24f107e2cc7f48e571a37e8e93b0cda?ts=2

ioquatix commented 6 years ago

Sorry, not trying to spam, just trying to help with other suggestions :)

dblock commented 5 years ago

This is still an ongoing problem, so I could still use some help. What I am seeing is that the run loop still sits inside a read, but that the goes offline.

Debugging messages that are being sent back and forth, next. @tarcieri When you have a second, would you be so kind to share any better logging code that I can add inside the read that would be helpful? Currently I do:

def handle_read(buffer)
  logger.debug("#{self.class}##{__method__}") { buffer }
  driver.parse buffer
end

This produces

D, [2018-08-19T14:27:35.200204 #212] DEBUG -- Slack::RealTime::Concurrency::Celluloid::Socket#handle_read: ?
D, [2018-08-19T14:27:35.200330 #212] DEBUG -- Slack::RealTime::Concurrency::Celluloid::Socket#write: ???6?

Not very useful. I could convert that data to some binary, but that's probably not much better. Maybe there's a parser I should add logging to? Any other recommendations?

I tried setting a global celluloid logger and not seeing anything from celluloid-io.

Celluloid.logger = ...
Celluloid.logger.level = Logger::DEBUG

Thanks.

dblock commented 5 years ago

Also, is there another driver than https://github.com/faye/websocket-driver-ruby that we should/could be using?