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...
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