Send periodic ping messages to keep connection open
Closed this issue · 1 comments
We noticed that the subscription will not receive new updates after running for a longer time, and will also not get an error on the error channel (we are not on latest master).
This is probably because the connection gets dropped because of inactivity by a load balancer on the relay side. In order to fix this we could add periodic ping message and return an error if we don't get a pong response in time.
FYI, d3a1624 doesn't actually do anything, because the defer ticker.Stop
happens immediately (the function does not block after it).
I would also prefer a procedure similar to https://github.com/gorilla/websocket/blob/master/examples/chat/client.go#L62 , requiring pong messages to be received every X seconds or otherwise returning an error. I would also prefer the use of an error channel to communicate this back to the user of this library.
I'm working on a fork of this lib with an error channel and a ping/pong mechanism at https://github.com/getAlby/go-nostr/.