RadarTech / lnrpc

A Typescript gRPC client for LND with support for all LND sub-servers
MIT License
43 stars 13 forks source link

Error: 2 UNKNOWN: Stream removed #49

Closed Janaka-Steph closed 4 years ago

Janaka-Steph commented 5 years ago

Hello,

Version used: 0.6.0-beta.3

I have an issue with SubscribeInvoices. After 10 to 15 minutes, the connection ends with Error: 2 UNKNOWN: Stream removed. I found a similar issue here https://github.com/grpc/grpc-node/issues/708

Someone on the LND slack has suggested to increase connection_idle, connection_age and the keepalive settings for the grpc channel. The parameters should be added here https://github.com/RadarTech/lnrpc/blob/master/lib/lightning.js#L49 The grpc documentation: https://grpc.github.io/grpc/cpp/group__grpc__arg__keys.html

Currently I get around the issue with a setInterval monitoring and retrying connection upon error. But I would be interested to have your opinion about the issue and suggested fix. Maybe allowing the end-user of lnrpc to set those parameters in the createLnRpc options object would be nice. What do you think?

Thank you

cavanmflynn commented 5 years ago

Sorry for the delay, @Janaka-Steph. I'm attempting to reproduce now. If I can, I'd be more than happy to add a couple grpc args to fix the issue. Will update soon.

cavanmflynn commented 5 years ago

I can't reproduce against LND v0.7.0-beta. I kept the subscribeInvoices stream open for an hour w/ no messages without error. Can you reproduce in v0.7.0-beta or higher, @Janaka-Steph ?

Janaka-Steph commented 5 years ago

To update lnrpc to v0.7.0-beta I have to use the npm run update-proto command?

Janaka-Steph commented 5 years ago

By the way, my app is https://github.com/bitcoin-studio/LightningNespressoUI And the setInterval hack is here https://github.com/bitcoin-studio/LightningNespressoUI/blob/master/server/index.ts#L195

cavanmflynn commented 5 years ago

@Janaka-Steph Nope, you'll just need to update the version in your package.json.

^0.7.0-beta.0 if you're using LND v0.7.0-beta OR ^0.7.1-beta if you're using LND v0.7.1-beta

Janaka-Steph commented 5 years ago

Hello! So I have updated lnrpc to v0.7.1-beta. I still have the error in prod on digital ocean, but can't reproduce on local.. So maybe there is something else than lnrpc. I don't know if you want to dive further, we can also close the issue and someone may reopen it later.

panoti commented 5 years ago

I think this error come from grpc.

Janaka-Steph commented 5 years ago

By pinging LND every 5 minutes (with GetInfo) I get rid of the errors 2 UNKNOWN: Stream removed and 14 UNAVAILABLE. My guess is that my nginx configuration is the issue, need more investigation.

jake-unl commented 4 years ago

Hi Janaka-Steph,

Did you get anywhere with this error? Was it indeed coming from grpc?

J

Janaka-Steph commented 4 years ago

Hello @jake-unl,

No I have never been able to fix it and I still don't know the cause. I recently moved to the ln-service library. I still ping the node because I still loose the connection after some minutes, but ln-service is more stable, even if I don't ping, my app will still be able to work properly and reconnect by himself. I am sorry if I am not clear enough, it's hard to explain like that.

parkergordonio commented 4 years ago

This is because the proxy or gRPC server is expecting traffic over TLS/SSL btw @jake-unl @Janaka-Steph

Janaka-Steph commented 4 years ago

Oh wow, this issue caused me so much trouble, thank you @parkergordonio !