ElementsProject / lightning

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

lightning-cli: Connecting to 'lightning-rpc': No such file or directory #795

Closed irishismyname closed 6 years ago

irishismyname commented 6 years ago

Trying to start up a mainnet lightning node, used this as a reference:

https://interfect.github.io/#!/posts/009-Ride-the-Lightning.md

bitcoin cli seems to work without a hitch (although it's still syncing), but I can't seem to get lightning to go.

Here's the output from starting the lightningd:

image

I should mention I have no idea what I'm doing here, but I want to get involved.

ronaldvdmeer commented 6 years ago

lighting-rpc has a spelling error in it. Its lightning-rpc (with an N) and can be found in the directory defined as --lightning-dir

irishismyname commented 6 years ago

Good catch, that turned out to be my careless spelling in the post (which I corrected just now).

ronaldvdmeer commented 6 years ago

It was not my intention to correct your spelling of your post :) I had hoped this spelling mistake was also the reason of the "file that can not be found" error.

Could you share with us the command you're using to startup the daemon?

irishismyname commented 6 years ago

Yes I was also hopeful of that haha.

I think (or hope) I'm starting cdecker's lightning image in the same namespace that amacneil's bitcoin image is running.

docker run --rm --name lightning --network container:bitcoind_mainnet -v /scratch/bitcoin/mainnet/bitcoind:/root/.bitcoin -v /scratch/bitcoin/mainnet/clightning:/root/.lightning --entrypoint /usr/bin/lightningd cdecker/lightningd:master --network=bitcoin --log-level=debug

I also wrapped the cli per the tutorial: #!/usr/bin/env bash docker run --rm -v /scratch/bitcoin/mainnet/clightning:/root/.lightning --entrypoint /usr/bin/lightning-cli cdecker/lightningd:master "$@"

running this script with getinfo as the argument returns the error in the title.

cdecker commented 6 years ago

I tried to reproduce this, but couldn't. I usually use exec to execute something inside of a running container. In this case I'd use

docker exec lightning lightning-cli getinfo

This sidesteps any problems that might appear due to wrong paths and does not leave containers around in case of failures :-)

irishismyname commented 6 years ago

I'm not getting any other console messages from lightning other than what's in the screenshot above. I was expecting to see "adding block", etc. per the tutorial. Is the lack of additional output caused by bitcoind still attempting to sync and download blocks? Should I wait for it to finish before attempting to run the daemon or CLI?

cdecker commented 6 years ago

Oh, I see, that might indeed be the issue, that you're not syncing with the blockchain. Can you try the following:

docker exec lightning bitcoin-cli getblockchaininfo

That tests that bitcoin-cli is able to talk to bitcoind from inside the lightningd container.

irishismyname commented 6 years ago

Seems to be working, the "blocks" count matches the current count reported by the bitcoin daemon.

irishismyname commented 6 years ago

Well I started over using:

https://medium.com/@dougvk/run-your-own-mainnet-lightning-node-2d2eab628a8b

as a reference, and it seems to be working now. Now to figure out the difference...

ShubhamBhut commented 1 year ago

Hi, actually I am getting this issue currently, I am running bitcoin on regtest and getting lightning-cli: Connecting to 'lightning-rpc': No such file or directory

no commands are working except -h and -V, every other command is giving this error. My lightningd seems to be running fine. An lightning-rpc file has also been generated at .lightning/regtest/

vincenzopalazzo commented 1 year ago

What is the command line that you are try to running?

ShubhamBhut commented 1 year ago

Solved, Actually I was passing the terminal modifier to the daemon but not the cli, that's why lightningd was running but lightning-cli was giving error. I just set regtest as default network in config and problem fixed.

VexTatarevic commented 1 year ago

When using custom directory for lightning instead of default one ~/.lightning , ... this is absolutely NOT WORKING as documented and described in official documentation at https://docs.corelightning.org/docs/configuration

Documentation says you can set rpc-file=/path/to/lightning/bitcoin/lightning-rpc inside your config fild and it should work ... but it does not work. The lightning deamon gets started without problems and creates lightning-rpc socket file in the location you set in config's rpc-file setting ... BUT when you run ANY lightning-cli command you will get: "lightning-cli: Connecting to 'lightning-rpc': No such file or directory"

... UNLESS you provide a command line argument for rpc-file EVERY single time you run any command like this: lightning-cli --rpc-file=/path/to/lightning/bitcoin/lightning-rpc getinfo

Is there no better way to do this ?

Shouldn't the lightning-cli command read the lightning-rpc socket location from the config file's setting "rpc-file" ?

My use-case and reason for using custom lightning directory location: I am using Raspberry Pi to host Lightning. I have to put the lightning folder in custom location on the mounted SSD Drive in order to preserve the disc space on the tiny 32 gb SD card that Raspberry runs off. Since the default location for lightning is in ~/.lightning that is located on SD card, that is not acceptable.

vincenzopalazzo commented 1 year ago

@VexTatarevic impossible that it is not working, I am using a custom path on my system.

I think what you want is --data-dir and not rpc-file?

Shouldn't the lightning-cli command read the lightning-rpc socket location from the config file's setting "rpc-file" ?

It does, you are just overriding it with the command line argument

VexTatarevic commented 1 year ago

@vincenzopalazzo --data-dir is not even a core lightning configuration argument as far as I can see on this documentation page : https://docs.corelightning.org/docs/configuration

Did you mean "datadir" setting in bitcoin.conf ? ... I have that set up and my bitcoin node runs as expected or did you mean "bitcoin-datadir" setting in lightning config file ? ...I have that set up fine or did you mean "lightning-dir" setting in lightning config file ? ... I have that set up as well pointing to the root folder of lightning

I will describe here my full structure and give the full config file and how I run it. Maybe that helps figure out what is the problem:

I get the following output which indicates that lightning is running fine:

2023-07-31T06:13:02.218Z INFO    connectd: Static Tor service onion address: "jhgjhgjhgjhgjhgjhgjhgjhgjhgjhgjhgjhgjhg.onion:9735,127.0.0.1:9734" bound from extern port 9735
2023-07-31T06:13:02.915Z INFO    plugin-bcli: bitcoin-cli initialized and connected to bitcoind.
2023-07-31T06:13:03.572Z UNUSUAL lightningd: Waiting for bitcoind to catch up (801005 blocks of 801025)
2023-07-31T06:13:04.674Z INFO    lightningd: --------------------------------------------------
2023-07-31T06:13:04.674Z INFO    lightningd: Server started with public key 987987987987987987999...., alias vexit (color #000000) and lightningd v23.05-154-g7a57f70
2023-07-31T06:13:25.455Z UNUSUAL plugin-bookkeeper: Snapshot balance does not equal ondisk reported 0msat, off by (+0msat/-0msat) (account wallet) Logging journal entry.
vincenzopalazzo commented 1 year ago

Sorry I did not remember the correct name

➜  ~ lightningd --help | grep dir                                  
--lightning-dir=<dir>                            Set base directory: network-specific
                                                 subdirectory is under here
--plugin-dir <arg>                               Add a directory to load plugins from
                                                 directory. This option may be specified
--bitcoin-datadir <arg>                          -datadir arg for bitcoin-cli
--bookkeeper-dir <arg>                           Location for bookkeeper records.
--fetchinvoice-noconnect                         Don't try to connect directly to fetch
➜  ~ 
VexTatarevic commented 1 year ago

@vincenzopalazzo thanks for your effort, but none of that helps because as I clearly described in the message above, I have already set lightning-dir and bitcoin-datadir in my config file. If you scroll down on my large post above you will see these settings in my lightning config that I provided.

It would be nice if you can do what I did in my message above and post here your config file and describe where your lightning data dir and bitcoin data dir are placed. If your setup is really working properly then there is no reason why it shouldn't work for me if I follow your setup description.

Cheers

vincenzopalazzo commented 1 year ago

Please do not blame me to did not read your comment, in your message before you says

And I get this lightning-cli: Connecting to 'lightning-rpc': No such file or directory

Then I run the same command with rpc-file path provided in full: lightning-cli --rpc-file=/home/ssd/crypto/lightning/bitcoin/lightning-rpc stop

And I get a correct response: "Shutdown complete"

Now, my question for you in previous posts before is, can you tell my how lightning-cli can now that your configuration file is in the /home/ssd/crypto/lightning/?

If you apply my suggestion [here](https://github.com/ElementsProject/lightning/issues/795#issuecomment-1658187799 and apply the lightning-cli works you should provide or --lightning-dir= or --rpc-file

The problem is that you are assuming that lightning-cli know your path, but it does not and you need to specify it each time that you use it.

ofc you can create an alias in your machine

VexTatarevic commented 1 year ago

The Lightning-cli should know where my config file is because I run the daemon with —conf argument like this : lightningd --conf=/home/ssd/crypto/lightning/config

and because I have set both lightning-dir and rpc-file inside the config.

The whole point of config file is to provide settings in it, so you don’t have to keep typing them in the command line every time you run lightning-cli command

This is also exactly how bitcoin-cli works. It reads settings from bitcoin.conf

If what you are saying is correct and I have to type —rpc-file argument every time I run lightning-cli command, then that’s obviously a bad program design by core Lightning. Cli is meant to be short and convenient for running commands.

Anyway thanks for trying to help. I’ll leave this issue at this and just use whatever works.

Cheers

vincenzopalazzo commented 1 year ago

If what you are saying is correct and I have to type —rpc-file argument every time I run lightning-cli command, then that’s obviously a bad program design by core Lightning. Cli is meant to be short and convenient for running commands.

PR are welcome if you are able to do better

VexTatarevic commented 1 year ago

You have a point :-) I didn’t mean to sound ungrateful. I guess it’s just a point for improvement or a feature request 😅 Thanks again