Open theronic opened 5 years ago
The closest thing I can find is this clj-pcp-client source file, which implements its own Websocket client interface to trigger a heartbeart and call .sendPing on the underlying socket implementation. It would be convenient if Gniazdo would give me access to the underlying websocket-client so I didn't have to mock out the whole interface (maybe it does already).
Managed to implement heartbeat pinging like this:
(ws/connect remote-host
:on-connect (fn [session]
(go-schedule! ws-heartbeat-interval-ms kill-chan
#(when (.isOpen session)
(log/debug "Pinging " session (.. session (getRemote) (sendPing (ByteBuffer/allocate 1)))))))
....
@theronic awesome. Did you figure out how to listen for the corresponding pong event?
How do I tell Gniazdo tot tell Jetty to keep the websocket connection alive with ping & pong messages every N seconds?
My websocket client connections to a server expecting pings are being forceably closed (code: 1006) because I'm not keeping the connection alive with ping/pong messages.