Skip to content
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

Easy way to handle disconnections? #14

Closed
sardaukar opened this issue Apr 19, 2020 · 5 comments
Closed

Easy way to handle disconnections? #14

sardaukar opened this issue Apr 19, 2020 · 5 comments

Comments

@sardaukar
Copy link

When I use curl to poll events, all goes well but as soon as I exit curl I get:

GET /reload_events/ - Unhandled exception:
Error writing to socket: Broken pipe (IO::Error)
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/socket.cr:82:13 in 'unbuffered_write'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/io/buffered.cr:218:5 in 'flush'
  from lib/sse/src/sse/server_sent_events_handler.cr:32:9 in 'sink'
  from lib/sse/src/sse/server_sent_events_handler.cr:37:53 in 'run'
  from lib/sse/src/sse/server_sent_events_handler.cr:54:11 in 'call'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handlers/compress_handler.cr:12:5 in 'call'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handlers/log_handler.cr:11:30 in 'call'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/handlers/error_handler.cr:15:7 in 'call'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/request_processor.cr:48:11 in 'process'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server/request_processor.cr:22:3 in 'process'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server.cr:498:5 in 'handle_client'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/http/server.cr:464:13 in '->'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/fiber.cr:255:3 in 'run'
  from /home/sardaukar/.asdf/installs/crystal/0.34.0/share/crystal/src/fiber.cr:92:34 in '->'
  from ???

Is there a best-practice on catching disconnections? Thanks!

@y2k2mt
Copy link
Owner

y2k2mt commented Apr 20, 2020

Thank you for reporting!
This problem does not seem to be reproducible in my environment.
Can you show me the implementation of HTTP::ServerSentEvents::Handler?

@sardaukar
Copy link
Author

This seems to be a problem with how Crystal handles EPIPE. I've opened an issue because I gave up on SSE and moved to WebSockets but it keeps happening crystal-lang/crystal#9135

Interesting that it doesn't happen for you... are you on Linux or Mac?

@y2k2mt
Copy link
Owner

y2k2mt commented Apr 20, 2020

Thank you for sharing. I will subscribe to them.

Interesting that it doesn't happen for you... are you on Linux or Mac?

I've tested it on Debian and Mac, and both environments finish a process without any output.
It seems to ignore an error on disconnection.

crystal-lang/crystal#9065 (comment)

@rdp
Copy link

rdp commented Apr 21, 2020

How to repro the issue, exacly?

@sardaukar
Copy link
Author

I have a repo up to help reproduce it https://github.com/sardaukar/websocket_issue but I've worked around it now. Thanks anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants