Pages:
Author

Topic: [solved] LNBits won't start due to python error - page 2. (Read 317 times)

legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
Can you post the config of the nginx file?

That error usually occurs when the browser thinks its connecting with ssl / https but the server is just putting out non https on that port.
Going offline till the morning, but you can probably google it.

-Dave
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Well, I need to reformulate this thread. It happens that I just noticed that I had one instance of LNBits running within screen.

So, the problem is now different. I can't make it work on https! I'll rework the original thread to reformulate the problem!


Edited;

Well, maybe I don't need to reformulate the original thread and instead just post here the new problem!

So, the only different thing is that LNBits is running but only on http. I have the ssl certificates set up, I have them in nginx config file, but if I try to use https I get this error on my laptop web browser:

Code:
Secure Connection Failed

An error occurred during a connection to 192.168.1.153:5000. SSL received a record that exceeded the maximum permissible length.

Error code: SSL_ERROR_RX_RECORD_TOO_LONG

    The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    Please contact the web site owners to inform them of this problem.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
Hello

I'm trying to setup my LNBits manually without using the easy way which is installing Caddy. I want to set it up by hand and have full control of what is going on.
My setup is the following:

Device: RockPro64
Router: NetGear R7800 running OpenWrt
OS: Debian BullsEye - Linux rockpro64 5.10.0-8-arm64 #1 SMP Debian 5.10.46-4 (2021-08-03) aarch64 GNU/Linux

LN node: C-Lightning v0.10.1-38-g8f782b0
LNBits: repository cloned from github, so I think it's master branch version
Web Server: nginx/1.18.0

I follwoned these steps to install LNBits, from their github:
Code:
git clone https://github.com/lnbits/lnbits.git
cd lnbits/
# ensure you have virtualenv installed, on debian/ubuntu 'apt install python3-venv' should work
python3 -m venv venv
./venv/bin/pip install -r requirements.txt
cp .env.example .env
mkdir data
./venv/bin/quart assets
./venv/bin/quart migrate
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'

I also watched this video, until Caddy part:
https://www.youtube.com/watch?v=WJRxJtYZAn4

My LNBits .env file is like this (the relevant parts):
Code:
$ cat .env
QUART_APP=lnbits.app:create_app()
QUART_ENV=development
QUART_DEBUG=true

HOST=127.0.0.1
PORT=5000

LNBITS_ALLOWED_USERS=""
LNBITS_DEFAULT_WALLET_NAME="LNBits wallet"

LNBITS_DATA_FOLDER="./data"

# disable selected extensions, or use "all" to disable all extensions
LNBITS_DISABLED_EXTENSIONS="amilk,ngrok"
LNBITS_FORCE_HTTPS=true
LNBITS_SERVICE_FEE="0.0"

# Change theme
LNBITS_SITE_TITLE="LNbits"
LNBITS_SITE_TAGLINE="free and open-source lightning wallet"
LNBITS_SITE_DESCRIPTION="My awesome message"

# Choose from mint, flamingo, salvador, autumn, monochrome, classic
LNBITS_THEME_OPTIONS="mint, flamingo, classic, autumn, monochrome, salvador"

# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet (gRPC),
#             LndRestWallet, CLightningWallet, LNbitsWallet, SparkWallet
LNBITS_BACKEND_WALLET_CLASS=CLightningWallet

# CLightningWallet
CLIGHTNING_RPC="/home/rp64/.lightning/bitcoin/lightning-rpc"


My nginx config file, which is in /etc/nginx/conf.d/my.awesome.lnbits.site.com is like this:
Code:
server {
   listen 5000 ssl http2 default_server;
   listen [::]:5000 ssl http2 default_server;
   server_name my.awesome.lnbits.site.ddns.net; # ---------> this site name is setup in in noip.com to avoid IP changes, if they happen

   ssl_certificate /etc/nginx/ssl/my.awesome.lnbits.site.crt;
   ssl_certificate_key /etc/nginx/ssl/my.awesome.lnbits.site.key;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

   location / {
      proxy_pass https://localhost:5000/; # ----> directive that sets up the reverse proxy in nginx
   }
}

My /etc/nginx/sites-available/default files is the default one. Didn't touch it!

My router firewall rule to forward the traffic to my rp64 is the following:
Code:
config redirect                                                                
        option dest_port '5000'                                                
        option src 'wan'                                                        
        option name 'lnbits'                                                    
        option src_dport '5000'                                                
        option target 'DNAT'                                                    
        option dest_ip '192.168.1.153'                                          
        option dest 'lan'                                                      
        option proto 'tcp'

So, after all this, when I try to run the command:
Code:
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'

I get this error:
Code:
 ✔️ CLightningWallet seems to be connected and with a balance of [i]not enough[/i] msat.
Traceback (most recent call last):
  File "/home/rp64/Downloads/lnbits/./venv/bin/hypercorn", line 8, in
    sys.exit(main())
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/__main__.py", line 267, in main
    run(config)
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/run.py", line 34, in run
    worker_func(config)
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/trio/run.py", line 119, in trio_worker
    trio.run(partial(worker_serve, app, config, sockets=sockets, shutdown_trigger=shutdown_trigger))
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/trio/_core/_run.py", line 1896, in run
    raise runner.main_task_outcome.error
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/trio/run.py", line 51, in worker_serve
    sockets = config.create_sockets()
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/config.py", line 177, in create_sockets
    insecure_sockets = self._create_sockets(self.bind)
  File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/config.py", line 240, in _create_sockets
    sock.bind(binding)
OSError: [Errno 98] Address already in use

If I use http://my.awesome.lnbits.site.ddns.net:5000, the site works, no idea how if LNBits is not running!


Note: I changed some folder names so that I can keep some of my privacy. I also changed the site name for the same reasons. So, this location "/home/rp64/Downloads/ doesn't really exist, but you all get the point. Same for the site name my.awesome.lnbits.site.ddns.net and ssl certificates.
Pages:
Jump to: