diff --git a/lib/landline/extensions/websocket.rb b/lib/landline/extensions/websocket.rb index ee2a15b..9678813 100644 --- a/lib/landline/extensions/websocket.rb +++ b/lib/landline/extensions/websocket.rb @@ -125,6 +125,10 @@ module Landline type: type ) @io.write(frame.to_s) + rescue Errno::EPIPE => e + @writable = false + _emit :error, e + close end # Read data from socket synchronously @@ -219,6 +223,10 @@ module Landline frame = @frame_parser.next return frame if frame end + rescue Errno::ECONNRESET => e + @writable = false + _emit :error, e + close end # Close the websocket