lightninglabs / lnc-web

Lightning Node Connect npm module for web
https://docs.lightning.engineering/lightning-network-tools/lightning-terminal/lnc-npm
48 stars 17 forks source link

LNC gets stuck in an infinite loop if it cannot connect #83

Open rolznz opened 1 year ago

rolznz commented 1 year ago

Hi, Alby allows users to connect to their node through an LNC connector

However, we have some cases where the lightning terminal is not running or not reachable, therefore the connection can never succeed, and we are unable to stop lnc from running even after lnc.disconnect();

Ideally if lnc.disconnect is called() LNC should not repeatedly try to re-connect (especially if it couldn't connect in the first place)

If connect() fails (or lnc.isConnected() returns false), should we still call disconnect()?

This set of logs gets repeated endlessly:

index.js:2 2023-06-13 19:47:07.451 [DBG] MBOX: Client: receive mailbox initialized
index.js:2 2023-06-13 19:47:07.783 [DBG] MBOX: Client: got failure on receive socket/stream, re-trying: {"code":2,"message":"stream not found","details":[]}
index.js:2 2023-06-13 19:47:08.815 [DBG] MBOX: Client: Attempting to create send socket/stream
index.js:2 2023-06-13 19:47:09.660 [DBG] MBOX: Client: Connected to send socket/stream
index.js:2 2023-06-13 19:47:10.739 [DBG] MBOX: Client: receive mailbox initialized
index.js:2 2023-06-13 19:47:11.065 [DBG] MBOX: Client: got failure on receive socket/stream, re-trying: {"code":2,"message":"stream not found","details":[]}
index.js:2 2023-06-13 19:47:13.687 [DBG] MBOX: Client: got failure on send socket/stream, re-trying: failed to write: WebSocket closed: unclean connection close: status = StatusAbnormalClosure and reason = ""
levmi commented 1 year ago

Hi, thanks so much for the report and feedback! We'll have someone take a look into this over the next sprint cycle or so (couple of weeks). We'll respond here as we find the issue and make any necessary fixes :)

lnbc1QWFyb24 commented 6 months ago

I am also running in to this issue. If the user inputs an already used pairing phrase (or anything that would cause the connection to fail), even after calling disconnect, LNC continues to keep trying to connect on a loop even if a new connection has been made that is successful.