add timeout to websocket reconnect
This commit is contained in:
parent
7fc8cd9dcd
commit
bea3e72c10
2 changed files with 11 additions and 2 deletions
|
|
@ -53,6 +53,7 @@
|
|||
pb/save-post)))))
|
||||
|
||||
(def socket (atom nil))
|
||||
(declare start)
|
||||
(defn connect []
|
||||
(tel/log! :info "Opening websocket connection to nostr relay")
|
||||
(reset! socket @(ws/websocket (@config :nostr-relay)
|
||||
|
|
@ -60,7 +61,11 @@
|
|||
:on-message (fn [_ws msg _last?]
|
||||
(process-msg msg))
|
||||
:on-close (fn [_ws status reason]
|
||||
(tel/log! {:level :warn :data {:status status :reason reason}} "WebSocket connection closed"))})))
|
||||
(tel/log! {:level :warn :data {:status status :reason reason}} "WebSocket connection closed")
|
||||
(future
|
||||
(Thread/sleep (* 5 60 1000))
|
||||
(tel/log! :info "Reconnecting WebSocket")
|
||||
(start)))})))
|
||||
|
||||
(defn subscribe-to-author [pubkey since]
|
||||
(let [sub-id (@config :nostr-fetcher-id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue