Exception in WebSocket disconnection with Kemal

75 views
Skip to first unread message

Juan Miguel Mora Carrera

unread,
Sep 30, 2018, 1:52:14 PM9/30/18
to crysta...@googlegroups.com
Hello All,

I am playing with Kemal and the WebSockets client library. My test is quite simple. On the one hand I have the standard Kemal chat's example as the server, on the other hand, the code below as the client:

s = HTTP::WebSocket.new("localhost", "/chat", port: 3000)

s.on_message(&->(message : String) {
puts message
# sleep 1
s.send("test")
nil
})

s.send("test")
s.run

Everything works fine, except for when one of the clients disconnects. In that case an exception is raised on the server...

[development] Kemal is ready to lead at http://0.0.0.0:3000
2018-09-30 15:40:57 +02:00 101 GET /chat 786.91ms
Exception: Error reading socket: Connection reset by peer (Errno)
  from /usr/local/Cellar/crystal/0.26.1_1/src/socket.cr:55:9 in 'unbuffered_read'
  from /usr/local/Cellar/crystal/0.26.1_1/src/io/buffered.cr:227:5 in 'fill_buffer'

...and then it stops working. The problem increases with the number of clients. I have found similar issues in the Github's repo, but not a solution for that.

Please, do you have any clue about what could be the problem?

Thank you.

Juan Miguel


Roger Pack

unread,
Oct 10, 2018, 11:20:42 PM10/10/18
to Crystal
Full backtrace please?
Reply all
Reply to author
Forward
0 new messages