alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

LND runs out of file descriptors #136

Closed apotdevin closed 2 years ago

apotdevin commented 3 years ago

Is there a way to close previous connections that are made? Or close them after the information is received?

Theres this issue that after a while LND runs out of file descriptors and the grpc calls stop working. Referring to this issue https://github.com/apotdevin/thunderhub/issues/172

alexbosworth commented 3 years ago

Can you tell me which subscription causes the issue? I can probably fix this if you can figure out which subscription causes it

apotdevin commented 3 years ago

ThunderHub is constantly polling getWalletInfo, getClosedChannels, getChainBalance, getPendingChainBalance and getChannelBalance

Since just leaving thunderhub open increases the file descriptors I'm thinking it must be one of those

alexbosworth commented 3 years ago

What about subscriptions?

alexbosworth commented 3 years ago

Are you recycling the lnd object or creating new lnd objects all the time?

apotdevin commented 3 years ago

Only using subscribeToInvoice but this is only called at a specific point.

Ah good point, it's creating a new lnd object for each call

alexbosworth commented 3 years ago

Yes you should re-use the LND object, let me know if that solves it

I will look into subscribeToInvoice as well

apotdevin commented 3 years ago

Will give it a try, almost sure this is the issue. Thanks for the tip!

alexbosworth commented 3 years ago

Another thing if you do recycle the LND, consider that if there is a networking error or something you may want to refresh it

apotdevin commented 3 years ago

And is there a correct way to deal with old lnd objects or how are this used connections closed?

alexbosworth commented 3 years ago

And is there a correct way to deal with old lnd objects or how are this used connections closed?

I'm not sure, I would have thought that if you delete references to the grpc connection that it closes itself, but that may not be the case

alexbosworth commented 3 years ago

I'll add a double check on the subscribe to invoice as well so that if you remove the listener it directly cancels the subscription

alexbosworth commented 3 years ago

There is now a check on the subscribeToInvoice method for the absence of listeners, which should now trigger a discrete cancel on the subscription