ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.84k stars 901 forks source link

Need help getting rid of "Address in use" issue #5069

Closed d4amenace closed 2 years ago

d4amenace commented 2 years ago

I have a freshly installed lighting node in a container that points to a seperate container that it uses to connect to bitcoind. I have setup Tor as well and I think my configuration might be incorrect.

Conf file:

alias= ^z  xxx ^z
bind-addr=0.0.0.0:9800
announce-addr=[my external ip]:9800
network=bitcoin
log-file=lightning.log
plugin=/root/c-lightning-events/websocket-events.js
websocket-events=all
websocket-port=8100
bind-addr=192.168.1.227:9800
announce-addr=xbsh3t64ezw5vqp5b6wmfyrq4x46heqzl27bcd6yy4qfjz$l.onion
proxy=127.0.0.1:9050
addr=statictor:127.0.0.1:9051
bitcoin-rpcconnect=192.168.1.135
bitcoin-rpcport=8336
bitcoin-rpcuser=nexxxxxxx
bitcoin-rpcpassword=J_fZxxxxxxxxxxxxxxxxxxxxxxxxxxxx

This is the error I get from logs:

2022-03-04T17:28:11.766Z **BROKEN** connectd: Failed to bind on 2 socket: Address already in use (version v0.10.2-329-g1da9b30)
mon/daemon.c:38 (send_backtrace) 0x5582acfdf17eacktrace: com$
mon/status.c:221 (status_failed) 0x5582acfecbd7acktrace: com$
nectd/connectd.c:1090 (make_listen_fd) 0x5582acfceeffce: con$
nectd/connectd.c:1129 (handle_wireaddr_listen) 0x5582acfcf002
nectd/connectd.c:1324 (setup_listeners) 0x5582acfcfa70e: con$
nectd/connectd.c:1517 (connect_init) 0x5582acfd03cdrace: con$
nectd/connectd.c:1896 (recv_req) 0x5582acfd1a58acktrace: con$
mon/daemon_conn.c:31 (handle_read) 0x5582acfdf418ktrace: com$
n/ccan/io/io.c:59 (next_plan) 0x5582ad0268ed: backtrace: cca$
n/ccan/io/io.c:407 (do_plan) 0x5582ad02748dd: backtrace: cca$
n/ccan/io/io.c:417 (io_ready) 0x5582ad0274cb: backtrace: cca$
n/ccan/io/poll.c:453 (io_loop) 0x5582ad0296e8 backtrace: cca$
nectd/connectd.c:2033 (main) 0x5582acfd1dd7d: backtrace: con$
ll):0 ((null)) 0x7f62a079809aOKEN** connectd: backtrace: (nu$
ll):0 ((null)) 0x5582acfc8ed9OKEN** connectd: backtrace: (nu$
ll):0 ((null)) 0xffffffffffffffff** connectd: backtrace: (nu$
TERNAL_ERROR: Failed to bind on 2 socket: Address already in use

2022-03-04T17:29:38.421Z **BROKEN** connectd: Failed to bind on 2 socket: Address already in use (version v0.10.2-329-g1da9b30)
mon/daemon.c:38 (send_backtrace) 0x5555d2f9f17eacktrace: com$
mon/status.c:221 (status_failed) 0x5555d2facbd7acktrace: com$
nectd/connectd.c:1090 (make_listen_fd) 0x5555d2f8eeffce: con$
nectd/connectd.c:1129 (handle_wireaddr_listen) 0x5555d2f8f002
2022-03-04T17:29:38.490Z **BROKEN** connectd: backtrace: connectd/connectd.c:1324 (setup_listeners) 0x5555d2f8fa70

Where am I going wrong?

vincenzopalazzo commented 2 years ago

Hi, can you try to remove one bind-addr from the conf?

d4amenace commented 2 years ago

Hello, I just redid an install on a new container. I have ensured lightning functions up to the tor install point. I then did a tor setup and was checking external ip and internal ip for matching for Case 2. I have done the full setup. I get one peculiar result when I check the internal ip with: ip route get 1 | awk '{print $NF;exit}'

I return: 0.

While the check for external ip address: curl ipinfo.io/ip ....returns my proper external ip address.

(1) Could this be the problem? I am creating the container inside proxmox. (ip routing needed?)

(2) I am running through a home router and isp. Do I need to open ports 9050 and 9051 on my router for tor?

(2a) And....if this is the issue, this means each container would need its own tor ports...so wouldn't it make sense to be able to deploy a single tor onion service on a container and do ip routing to it to retrieve ip addresses for all other c-lightning containers needing tor onion addresses (since I intend on running multiple c-lightning containers and each would need it's own lightning address)....or do some sort of nfs server since c-lightning requires a tor installed (all c-llightning instances could reference the central containers tor).

d4amenace commented 2 years ago

Current config:

alias= 
bind-addr=0.0.0.0:9800
announce-addr=(my_ip):9800
network=bitcoin
log-file=lightning.log
bitcoin-rpcconnect=192.168.1.135
bitcoin-rpcport=8336
bitcoin-rpcuser=nextlayer
bitcoin-rpcpassword=J_fZOsGNQIQDKJYxxxxxxxxxxxxxxxxx
plugin=/root/c-lightning-events/websocket-events.js
websocket-events=all
websocket-port=8100
bind-addr=127.0.0.1:9800
announce-addr=lfhvju6mzqakansfvet2x65j27gypwvokkvj6erx2pn7un$
proxy=127.0.0.1:9050
addr=statictor:127.0.0.1:9051
always-use-proxy=true
bind-addr=192.168.1.177:9800

Current error msg from lightning log:

2022-03-05T18:17:14.009Z INFO    connectd: Static Tor service onion address: "oxb6llpgh6ayzswzhwevdvk45dcsyd7snvbgyhwp4b2g42curhgg2rid.onion:9735,0.0.0.0:9800" bound $
2022-03-05T18:17:14.569Z INFO    plugin-bcli: bitcoin-cli initialized and connected to bitcoind.
2022-03-05T18:17:15.952Z **BROKEN** connectd: Failed to listen on socket 127.0.0.1:9800: Address already in use

Current error msg from inline print:

root@V ~# lightningd
Reading JSON input: Connection reset by peerReading JSON input: Connection reset by peer
Lost connection to the RPC socket.

Lost connection to the RPC socket.Reading JSON input: Connection reset by peer

Reading JSON input: Connection reset by peer
Reading JSON input: Connection reset by peer
root@V ~# node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:796:11)
    at Socket._write (node:net:808:8)
    at writeOrBuffer (node:internal/streams/writable:390:12)
    at _write (node:internal/streams/writable:331:10)
    at Socket.Writable.write (node:internal/streams/writable:335:10)
    at Plugin._write (/root/c-lightning-events/node_modules/clightningjs/src/plugin.js:40:25)
    at Plugin._writeJsonrpcResponse (/root/c-lightning-events/node_modules/clightningjs/src/plugin.js:116:16)
    at Plugin._mainLoop (/root/c-lightning-events/node_modules/clightningjs/src/plugin.js:201:22)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v17.6.0
d4amenace commented 2 years ago

UPDATE: I have removed all tor related information to make troubleshooting easier. I can get the node to connect to the bitcoind in the other container (via local NAT address ONLY, lightningd cannot remotely rpc connect to bitcoin through external ip address) but I cannot download any blocks ....so the getinfo call shows "0" blocks forever.....

root@V ~# lightning-cli getinfo
{
   "id": "0382cccccccc",
   "alias": " ^ccccc",
   "color": "0382d5",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [
      {
         "type": "ipv4",
         "address": "73.36.65.41",
         "port": 9800
      }
   ],
   "binding": [
      {
         "type": "ipv4",
         "address": "0.0.0.0",
         "port": 9800
      }
   ],
   "version": "v0.10.2-399-gb5a1715",
   "blockheight": 0,
   "network": "bitcoin",
   "msatoshi_fees_collected": 0,
   "fees_collected_msat": "0msat",
   "lightning-dir": "/root/.lightning/bitcoin",
   "warning_lightningd_sync": "Still loading latest blocks from bitcoind.",
   "our_features": {
      "init": "08026aa2",
      "node": "80000008026aa2",
      "channel": "",
      "invoice": "024200"
   }
}

My current config file:

announce-addr=[external_ip]:9800
network=bitcoin
log-file=lightning.log
bitcoin-rpcconnect=192.168.1.135
bitcoin-rpcport=8336
bitcoin-rpcuser=xxxx
bitcoin-rpcpassword=xxxxxxx
plugin=/root/c-lightning-events/websocket-events.js
websocket-events=all
websocket-port=8100
bind-addr=0.0.0.0:9800

I am still under the belief it has something to do with ip forwarding in proxmox due to:

".....when I check the internal ip with: ip route get 1 | awk '{print $NF;exit}'

I return: 0."

Any help would be greatly appreciated.

d4amenace commented 2 years ago

Hi, can you try to remove one bind-addr from the conf?

I figured it would be easier to just remove tor and see if the problem had nothing to do with tor, which seems to be the case.