From bfa4c728b0c6d2f0250352b7dcd803feb58ba06f Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 28 Feb 2023 19:20:13 +0100 Subject: [PATCH] [mod] Client will now re-connect on WebSocket send error Motivation: it's possible for WebSocket to get into bad state (e.g. by attempting close with invalid code). In this state, it's neither closed nor capable of successfully sending. Without this commit, the socket would needlessly remain in an unusable state until ws-ping failure. --- src/taoensso/sente.cljc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/taoensso/sente.cljc b/src/taoensso/sente.cljc index 07b8ee8..91549b2 100644 --- a/src/taoensso/sente.cljc +++ b/src/taoensso/sente.cljc @@ -54,7 +54,7 @@ :last-close - ?{:udt _ :reason _}, with reason e/o #{nil :clean :unexpected :requested-disconnect :requested-reconnect :downgrading-ws-to-ajax - :ws-ping-timeout} + :ws-ping-timeout :ws-error} :udt-next-reconnect - Approximate udt of next scheduled auto-reconnect attempt Notable implementation details: @@ -1101,7 +1101,7 @@ :requested-disconnect :requested-reconnect :downgrading-ws-to-ajax - :ws-ping-timeout}] + :ws-ping-timeout :ws-error}] reason) (let [closing? (:open? state) @@ -1396,6 +1396,8 @@ (have ?cb-fn))] (cb-fn* :chsk/error))) + (-chsk-reconnect! chsk :ws-error) + false)))))) (-chsk-connect! [chsk]