Question about the heartbeat
AdamGrzybkowski opened this issue · 6 comments
Will the error callback on PhxSocket be called when sending heartbeat fails?
From what I've seen it does not, but what is the purpose of the heartbeat then?
@dsrees hmm I think I know what could be the issue. If I'm not wrong the reconnectTimer is not initialized.
So basically if the heartbeat fails the connection is closed and nothing more happens.
Could you pls look at that?
Hm, good catch. If the heartbeat fails, the reconnect timer is supposed to trigger and attempt to re-establish with the server. I'll take a look into this. Thanks for reporting it!
I think this is whats missing AdamGrzybkowski@32c719f
But this still wouldn't make possible for me to know the status of heartbeat push. So I have to use autoreconnect
feature from the lib, because I cannot handle this myself.
That commit looks good, if you want to get a PR open
What are you trying to do specifically with the heartbeat?
PR created.
About the heartbeat.
Right now we do have a problem that sometimes WS connection is killed without any kind of callback (onError or onClose). The only way to know that it was dropped is the heartbeat (or more precisely when it fails), that's why I thought it would good to know that.
Ofc this is not needed if we can rely on the lib logic to reconnect but sometimes we might want sth more custom.
In my case I always want to keep the connection open so I had to add some reconnection logic when onError
is called as the lib was only handling reconnecting when the WS was closed(as it turned out it didn't :P). Right now to do what I need I will have to have reconnection logic: one handled by me and one by the lib. I would prefer to handle this in one place.
Available in 0.1.5