ElementsProject / lightning

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

Connecting to 'lightning-rpc': Connection refused #1123

Closed realcryptominer closed 6 years ago

realcryptominer commented 6 years ago

I have successfully installed C-lightning on Ubuntu 16.04 VPS and successfully made a first payment on starblocks coffee (virtual) purchase.

However, now I get the following error when I put command cli/lightning-cli help, getinfo, dev-blockheight, pay, decodepay or any other command.


Connecting to 'lightning-rpc': Connection refused

I have closed the node (with command cli/lightning-cli stop) and again restarted it with the following command.

lightningd/lightningd --network=testnet --log-level=debug

However, still the above error persists.

Following command gives perfect results and the matching/synchronized blockchain height.

bitcoin-cli -testnet getblockcount

Kindly do the needful.

ZmnSCPxj commented 6 years ago

Is lightningd still running? It seems to have crashed. Can you try to acquire the logs?

realcryptominer commented 6 years ago

Yeahh... Its still running....

Sure. I can acquire the logs.... How can I do that?

I am a total newbie. I am very much passionate about it so I have started it on my Linux VPS.

If you tell me how can I acquire the logs, I can post it here.

ZmnSCPxj commented 6 years ago

How did you run it? It also dumps its logs to its stdout. How do you know it is running? Can you show output of ps waux | grep lightningd ?

realcryptominer commented 6 years ago

This is the output.

root 21971 0.0 0.0 14224 968 pts/0 S+ 03:07 0:00 grep --color=auto lightning

I have started it by using the following command.

lightningd/lightningd --network=testnet --log-level=debug

ZmnSCPxj commented 6 years ago

lightningd stopped running; if it was still running then your ps waux | grep lightningd would have listed it.

Can you go back to the terminal/ssh session where you executed the lightningd command? If you closed it, that would have killed your lightningd too unless you were using screen or tmux. If you want to keep it running even after you close the terminal/ssh session then you should have started it with --daemon flag (note: --daemon was added recently and you might not have the latest version, and it was flaky recently too so you probably want the bleeding-edge version then)

realcryptominer commented 6 years ago

ohhh I see.... I did not know about this.

I have added following builds and repositories that included tmux.

sudo apt-get install -y autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev python python3 net-tools tmux

However, I am not sure I am using tmux or not?

I am using Putty from my Windows desktop to SSH connect my Lunux Ubuntu 16.04 VPS.

Now I have several times closed that command window.

Can u share some link on how can I start lightning with --daemon flag?

realcryptominer commented 6 years ago

By the way I have downloaded and installed Lightningd from following command. So I thought its up to date version!

git clone https://github.com/ElementsProject/lightning.git

realcryptominer commented 6 years ago

By the way when I am right now running the following command, its giving me this kind of things on my terminal at the moment.

lightningd/lightningd --network=testnet --log-level=debug


2018-02-28T02:29:20.713Z lightning_gossipd(22020): Received channel_announcement for channel 1230616:127:0 2018-02-28T02:29:20.715Z lightning_gossipd(22020): UPDATE WIRE_GOSSIP_GET_TXOUT 2018-02-28T02:29:20.715Z lightning_gossipd(22020): Received channel_announcement for channel 1259861:94:0 2018-02-28T02:29:20.715Z lightning_gossipd(22020): UPDATE WIRE_GOSSIP_GET_TXOUT 2018-02-28T02:29:20.715Z lightning_gossipd(22020): Received channel_announcement for channel 1275635:145:0 2018-02-28T02:29:20.715Z lightning_gossipd(22020): UPDATE WIRE_GOSSIP_GET_TXOUT 2018-02-28T02:29:20.715Z lightning_gossipd(22020): Received channel_update for channel 1259745:42:0(0) now DISABLED 2018-02-28T02:29:20.750Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.750Z lightning_gossipd(22020): Received channel_update for channel 1231701:42:1(1) now ACTIVE 2018-02-28T02:29:20.769Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.792Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.793Z lightning_gossipd(22020): Received channel_update for channel 1260733:17:0(0) now ACTIVE 2018-02-28T02:29:20.799Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.820Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.933Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.933Z lightning_gossipd(22020): Received channel_update for channel 1254516:37:0(0) now ACTIVE 2018-02-28T02:29:20.933Z lightning_gossipd(22020): Received channel_update for channel 1254516:37:0(1) now ACTIVE 2018-02-28T02:29:20.936Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.943Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.947Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.947Z lightning_gossipd(22020): Received channel_update for channel 1260883:32:1(0) now ACTIVE 2018-02-28T02:29:20.952Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.952Z lightning_gossipd(22020): Received channel_update for channel 1260841:88:0(0) now ACTIVE 2018-02-28T02:29:20.975Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.980Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.984Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.988Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:29:20.988Z lightning_gossipd(22020): Received channel_update for channel 1275635:145:0(0) now ACTIVE 2018-02-28T02:29:20.988Z lightning_gossipd(22020): Received channel_update for channel 1275635:145:0(1) now ACTIVE 2018-02-28T02:29:25.186Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_in WIRE_PING 2018-02-28T02:29:25.186Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: Got ping, sending WIRE_PONG 2018-02-28T02:29:25.186Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_out WIRE_PONG 2018-02-28T02:29:40.230Z lightning_gossipd(22020): peer_in WIRE_PING 2018-02-28T02:29:40.230Z lightning_gossipd(22020): peer_out WIRE_PONG 2018-02-28T02:29:50.650Z lightning_gossipd(22020): Received channel_update for channel 1260297:18:1(0) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1230645:122:0(1) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1230572:167:0(0) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1260916:40:0(0) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1230645:122:0(0) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1260841:88:0(1) now ACTIVE 2018-02-28T02:29:50.651Z lightning_gossipd(22020): Received channel_update for channel 1260733:17:0(1) now ACTIVE

realcryptominer commented 6 years ago

2018-02-28T02:32:51.093Z lightning_gossipd(22020): Received channel_update for channel 1284100:23:0(0) now ACTIVE 2018-02-28T02:32:51.117Z lightning_gossipd(22020): req: type WIRE_GOSSIP_GET_TXOUT_REPLY len 46 2018-02-28T02:32:51.117Z lightning_gossipd(22020): Received channel_update for channel 1260318:127:0(1) now ACTIVE 2018-02-28T02:33:11.195Z lightningd(22012): Adding block 1286754: 00000000c1776a471d38b958b5f39cfe2b6b9bb26c7f43a3c70623d95335f671 2018-02-28T02:33:20.656Z lightning_gossipd(22020): Received channel_update for channel 1260297:18:1(1) now DISABLED 2018-02-28T02:33:25.435Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_in WIRE_PING 2018-02-28T02:33:25.435Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: Got ping, sending WIRE_PONG 2018-02-28T02:33:25.435Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_out WIRE_PONG 2018-02-28T02:33:45.081Z lightning_gossipd(22020): peer_in WIRE_PING 2018-02-28T02:33:45.081Z lightning_gossipd(22020): peer_out WIRE_PONG 2018-02-28T02:33:50.592Z lightning_gossipd(22020): Received channel_update for channel 1284307:20:0(0) now ACTIVE 2018-02-28T02:34:20.664Z lightning_gossipd(22020): Received channel_update for channel 1282741:57:1(1) now ACTIVE 2018-02-28T02:34:20.665Z lightning_gossipd(22020): Received channel_update for channel 1283879:5:0(0) now ACTIVE 2018-02-28T02:34:20.665Z lightning_gossipd(22020): Received channel_update for channel 1282934:34:0(1) now ACTIVE 2018-02-28T02:34:20.665Z lightning_gossipd(22020): Received channel_update for channel 1286326:18:0(1) now ACTIVE 2018-02-28T02:34:25.436Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_in WIRE_PING 2018-02-28T02:34:25.436Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: Got ping, sending WIRE_PONG 2018-02-28T02:34:25.436Z lightningd(22012): lightning_channeld-0231eee2441073c86d38f6085aedaf2bb7ad3d43af4c0e2669c1edd1a7d566ce31 chan #4: peer_out WIRE_PONG 2018-02-28T02:34:40.698Z lightning_gossipd(22020): peer_in WIRE_PING 2018-02-28T02:34:40.699Z lightning_gossipd(22020): peer_out WIRE_PONG 2018-02-28T02:34:50.652Z lightning_gossipd(22020): Received channel_update for channel 1285446:12:0(1) now DISABLED 2018-02-28T02:34:50.652Z lightning_gossipd(22020): Received channel_update for channel 1280332:78:1(1) now ACTIVE

ZmnSCPxj commented 6 years ago

tmux is a terminal multiplexer, like screen. The important property of screen/tmux is that even if you disconnect, the screen/tmux running on the server will continue running and any programs you have running in the terminal inside the screen/tmux will continue running.

By default, in Linux, if you run a program in a terminal and then disconnect (i.e. close the terminal window), then that program gets terminated using SIGHUP signal. Providing --daemon flag tells lightningd to protect against this by forking itself twice (to "daemonize" itself).

So what you need to do now is:

  1. Terminate the running lightningd you have (close the terminal or Ctrl-C).
  2. Run git pull on the checked out source to update to latest source.
  3. Run make again to recompile latest source.
  4. Add --daemon to your command line: lightningd/lightningd --network=testnet --log-level=debug --daemon
  5. Afterwards, disconnect (close the terminal) then reconnect, and confirm that lightningd is still running: ps waux | grep lightningd
realcryptominer commented 6 years ago

Ahhh.... Awesome... It worked...

I have exactly did what u said above and it worked.

Timux is awesome. So the key here is to use Timux to keep open the sessions on Linux VPS. I have used Remote Desktop connection for Windows VPS before and that's why I assumed that when we close Putty, those sessions will keep opened.

So Silly I m... : )

I have closed Putty after using Timux and its working fine now.

Cheers... : )

root@vmi168564:~/builds/lightning# ps waux | grep lightningd │ root 15988 0.0 0.0 14224 972 pts/6 S+ 07:35 0:00 grep --color=│ auto lightningd │ root 18784 6.5 0.4 39600 25780 pts/4 S+ 07:29 0:21 lightningd/li│ ghtningd --network=testnet --log-level=debug │ root 18791 0.0 0.0 12136 4108 pts/4 S+ 07:29 0:00 /root/builds/│ lightning/lightningd/lightning_hsmd │ root 18792 4.4 0.7 52376 44312 pts/4 S+ 07:29 0:14 /root/builds/│ lightning/lightningd/lightning_gossipd │ root 18838 0.4 0.1 19608 11356 pts/4 S+ 07:29 0:01 /root/builds/│ lightning/lightningd/lightning_channeld │ root 19306 0.0 0.0 11144 2932 pts/4 S+ 07:29 0:00 /root/builds/│ lightning/lightningd/lightning_onchaind

berkinimamoglu commented 6 years ago

@ZmnSCPxj i did really messed up too man while i was trying to become node on lightning network . I did try google cloud computing for this but after i funded, and when i was checking lightning -cli fundchannel i did see that some of wording like gossiping as a status . So I did try to fix it but messed it up badly. Here is the snapshot of the current situation, Can you please help me

Connected, host fingerprint: ssh-rsa 2048 B4:B2:DE:7C:E2:1F:6A:54:D5:8C:5E:10:C1:0C:29:B8:3B:CF:BA:CE:EB:38:BD:93:65:E4:83:4C:9A:A8:A2:7A Welcome to Ubuntu 17.10 (GNU/Linux 4.13.0-39-generic x86_64)

ZmnSCPxj commented 6 years ago

There is no running lightningd, that is why ps waux | grep lightningd does not show a lightningd process. That is why you cannot connect to lightning-rpc.

Did you run lightningd as a daemon or a background process? Did you disconnect from your cloud server?

Do you use screen or tmux?

berkinimamoglu commented 6 years ago

not sure about that , how can i check that . i am a beginner :(

ZmnSCPxj commented 6 years ago

Did you know that if you have a program running on your server on your terminal program (Putty?) and you disconnect your local computer from the server, the program running on the server will be terminated?

The only way to prevent this would be to run as a daemon by adding --daemon to your arguments (note that daemon mode is sometimes flaky, so be prepared for trouble) or as a background process by appending a & to the end of its command line.

Also, learn about GNU screen or tmux. You can find out about them from google.

berkinimamoglu commented 6 years ago

got it, man is it possible to fix it with a quick skype call if you are available i can share my screen i really appreciate it if you are free.

berkinimamoglu commented 6 years ago

but i did rent a virtual machine from google cloud, didnt those computers still work if i still turned off my laptop

ZmnSCPxj commented 6 years ago

@berkinimamoglu, this behavior is the same for all Unix-likes, does not matter whether it is a virtual cloud machine or a room-sized server or a Raspberry Pi. If you run a program in a terminal, then hang up (disconnect), the foreground program is terminated. Unless you use & or nohup (which on modern Unix-likes are equivalent), in which case they are background programs. Or launch with --daemon flag. This has been a policy of Unix and its clones since the 1980s.

That is why I said, go learn GNU screen. Or tmux. Did you even attempt to Google them?

berkinimamoglu commented 6 years ago

i did fund my wallet while i was trying to install the lightning network. If i restore the Virtual Machine that i use to start everything from 0 , will it be messed up? will i be able to take back my btcs that I funded. What will happen to those funds that I sent to connect other nodes?

berkinimamoglu commented 6 years ago

to i need to erase all the files and start from 0 with the link u provided? or is there any other way to fix this?

ZmnSCPxj commented 6 years ago

Do not erase any files, you need them, else you will lose your funds. You just need to learn how to work in Linux. screen and tmux let you persist the terminal session even if you disconnect.

It seems to me you are in too deep. You need to learn Linux and general Unix-like administration and thinking.

Did you send to the lightningd instance or to the bitcoind instance? Do you know the difference?

berkinimamoglu commented 6 years ago

not sure about that, is there any chance that u can help me to fix this. I dont want to loose the funding. I am free rest of the day for a skype call if u r available.

JaviLib commented 2 years ago

Just to inform people: you will have this error if running in Docker in OSX or Windows, but not in Linux. This is due to a limitation in docker that cannot share rpc connections between machines in non-Linux hosts. Solution to this is to indicate in the config file a rpc file which is not in any volume. Example:

rpc-file=/socket

eliaspfeffer commented 7 months ago

Just to inform people: you will have this error if running in Docker in OSX or Windows, but not in Linux. This is due to a limitation in docker that cannot share rpc connections between machines in non-Linux hosts. Solution to this is to indicate in the config file a rpc file which is not in any volume. Example:

rpc-file=/socket

I have this error now on Linux: See my post