From 712046f5e8d613f10fc7857e25fe98139bc4f9fd Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 31 May 2022 10:01:54 +0200 Subject: [PATCH] [#403][Fix] Start ws-kalive loop only after conn is established (@Snurppa) Before this commit: `:chsk/ws-ping` loop starts before (connect-fn) is called. This means that if there's some delay establishing connection, the logs get needlessly polluted with messages: - "Chsk send against closed chsk." from the ws-ping send. - "Chsk is closed: will try reconnect" from the connection retry-fn. After this commit: Only start the ws-kalive loop after connection is established. --- src/taoensso/sente.cljc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/taoensso/sente.cljc b/src/taoensso/sente.cljc index c62fd81..a70bb32 100644 --- a/src/taoensso/sente.cljc +++ b/src/taoensso/sente.cljc @@ -1290,6 +1290,9 @@ (reset! socket_ ?socket))))))] + (reset! retry-count_ 0) + (connect-fn) + (when-let [ms ws-kalive-ms] (go-loop [] (let [udt-t0 @udt-last-comms_] @@ -1308,8 +1311,6 @@ (-chsk-send! chsk [:chsk/ws-ping] {:flush? true}))) (recur))))) - (reset! retry-count_ 0) - (connect-fn) chsk))) (defn- new-ChWebSocket [opts csrf-token]