From 20c312d9a987ac593a7aadb3103949367b6be207 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Sun, 7 Jul 2024 21:28:51 +0400 Subject: [PATCH] better websocket error handling --- lib/landline/extensions/websocket.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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