Closed bumi closed 9 months ago
nostr-tools now does this, but it's not published yet: https://github.com/nbd-wtf/nostr-tools/blob/HEAD/relay.ts
I made an example to test this locally where you can do:
This already works unless I switch WIFI networks.
I checked if I can get any error message, but relay.on("disconnect")
and relay.on("error")
never fires, and the underlying ws object is not exposed to the Relay, so we cannot access it directly. The status function always returns 1 even if the internet is disconnected, and the current version of nostr-tools always checks the ws readyState (which is always 1) so the reconnect logic never gets called :confused:
I think steps should be:
I was wrong. Fixed by https://github.com/getAlby/js-sdk/pull/172
Currently it seems that the NostrWeblnProvider is not reconnecting to the relay if the connection is lost and then the
checkConnected
function throws an error.Maybe we shoud auto-connect in the
checkConnected
function if the connection is not open?Then the question is if we need an additional
enabled
state to only do this when.enable()
was called before.