better websocket error handling

This commit is contained in:
Yessiest 2024-07-07 21:28:51 +04:00
parent a15e531fdc
commit 20c312d9a9
1 changed files with 8 additions and 0 deletions

View File

@ -125,6 +125,10 @@ module Landline
type: type type: type
) )
@io.write(frame.to_s) @io.write(frame.to_s)
rescue Errno::EPIPE => e
@writable = false
_emit :error, e
close
end end
# Read data from socket synchronously # Read data from socket synchronously
@ -219,6 +223,10 @@ module Landline
frame = @frame_parser.next frame = @frame_parser.next
return frame if frame return frame if frame
end end
rescue Errno::ECONNRESET => e
@writable = false
_emit :error, e
close
end end
# Close the websocket # Close the websocket