I have a proxy peer on the public cloud and IOT devices behind NATs that register their ids and multiaddrs with it using a public http API. The proxy adds the peer to the peerstore and then the IOT device address and then the IOT device establishes a stream to the proxy and neither closes this “opening” stream, creating the underlying connection. The proxy creates a new stream per request as per the examples using the already established connection.
So far so good, but what do I do when the connection or the peerstore goes down, say during a reboot / upgrade.
I’m considering a few strategies…
- Persist my registrations and load up the peerstore from the persistent data on bootup.
- Detect failed connections on the IOT device and re-register on failure.
- Reregister periodically.
I’m wondering if 1 would work, probably the mnksost elegant. Would the IOT peer reconnect to keep the opening stream alive?
How do I do 2? What’s the recommended way to detect a down connection / do a retry.
And 3. Yes. I can do it, but ugly.
Thanks for a great library everyone!