Blockstream / greenlight

Build apps using self-custodial lightning nodes in the cloud
https://blockstream.github.io/greenlight/getting-started/
MIT License
113 stars 28 forks source link

gl-client unrecoverable after network change #521

Open JssDWt opened 6 hours ago

JssDWt commented 6 hours ago

Whenever there's a network change, like switching from wifi to mobile data, gl-client is unable to reconnect to greenlight using the same grpc channel. This means an app using gl-client would have to be killed and restarted to recover.

Related Breez SDK issue here https://github.com/breez/breez-sdk-greenlight/issues/1090

Unfortunately it seems that tonic's Channel doesn't handle reconnection at all: https://github.com/hyperium/tonic/issues/1254 Meaning reconnection logic should be implemented manually in every client package.

cdecker commented 6 hours ago

Thanks @JssDWt I was unaware that tonic does not handle reconnections well. Do you have an idea we could use to detect and remedy such a system? I guess you have more experience dealing with flaky connections on the mobile side than we do.

JssDWt commented 6 hours ago

Do you have an idea we could use to detect and remedy such a system? I guess you have more experience dealing with flaky connections on the mobile side than we do.

We've been using golang grpc bindings in breezmobile, where reconnection is handled automatically by the grpc library. I'm looking into possible solutions.

JssDWt commented 6 hours ago

An idea is to use the timeout to detect hanging network connections. Problem is that it may be very slow, currently 10 minutes. We could use a lower timeout like this: https://github.com/hyperium/tonic/pull/662/files#diff-2dc4a5ebbcd9a8a198e55baa6958f271c1df257a9e3d6ae9c70295a4df7773deR133

And then manually reconnect whenever that timeout is hit.