donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python & Vue.js
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.54k stars 232 forks source link

it just crashes, randomly #432

Open reloadlife opened 1 week ago

reloadlife commented 1 week ago

Describe The Problem sometimes, randomly the panel crashes and i have to do a manual restart of it (./wgd.sh restart)

Expected Error / Traceback

[2024-10-18 15:32:02,053] ERROR in app: Exception on /api/getWireguardConfigurationInfo [GET]
Traceback (most recent call last):
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask_cors/extension.py", line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/opt/WGDashboard/src/dashboard.py", line 1917, in API_getConfigurationInfo
    "configurationPeers": WireguardConfigurations[configurationName].getPeersList(),
  File "/opt/WGDashboard/src/dashboard.py", line 909, in getPeersList
    self.__getPeers()
  File "/opt/WGDashboard/src/dashboard.py", line 678, in __getPeers
    self.Peers.append(Peer(i, self))
  File "/opt/WGDashboard/src/dashboard.py", line 963, in __init__
    self.getShareLink()
  File "/opt/WGDashboard/src/dashboard.py", line 1071, in getShareLink
    self.ShareLink = AllPeerShareLinks.getLink(self.configuration.Name, self.id)
  File "/opt/WGDashboard/src/dashboard.py", line 411, in getLink
    self.__getSharedLinks()
  File "/opt/WGDashboard/src/dashboard.py", line 406, in __getSharedLinks
    allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall()
  File "/opt/WGDashboard/src/dashboard.py", line 1425, in sqlSelect
    with sqldb:
sqlite3.DatabaseError: no more rows available

To Reproduce Please provide how you run the dashboard

OS Information:

Sample of your .conf file

[Interface]
Address = 172.16.0.1/18
Table = foo
SaveConfig = true
ListenPort = 51810
PrivateKey = [REDACTED]

[Peer]
PublicKey = [REDACTED]
AllowedIPs = 172.16.0.2/32
Endpoint = [REDACTED]

[Peer]
PublicKey = [REDACTED]
PresharedKey = [REDACTED]
AllowedIPs = 172.16.0.3/32
Endpoint = [REDACTED]

...
about 30-40 more peers ...
...

[Peer]
PublicKey = [REDACTED]
PresharedKey = [REDACTED]
AllowedIPs = 172.16.0.40/32
Endpoint = [REDACTED]

[Peer]
PublicKey = [REDACTED]
AllowedIPs = 172.16.0.41/32
donaldzou commented 1 week ago

Hi @reloadlife , after digging into this issue.. I couldn't find anything related to this error message, just wondering: does your memory or hard disk of your Ubuntu reached its limit?

I'll do more research and try to solve this issue :)

reloadlife commented 1 week ago

I was wondering the same thing, I've checked and I have plenty of storage and ram, so that can't be the case ...

donaldzou commented 1 week ago

Yeah.. Just posted a post on the SQLite forum and hope someone would know what's going on. It got me thinking: will it caused by Python 3.10?

I'll try it on a VM and see if I can recreate this issue

reloadlife commented 1 week ago

Can we possibly have version that uses SQL or PostgreSQL, if it is for sure caused by SQLite

donaldzou commented 1 week ago

We could, but this will need to rewrite most of the SQL statements. The easiest way is to catch the error and prevent the dashboard to crash.

Get Outlook for iOShttps://aka.ms/o0ukef


From: reloadlife @.> Sent: Saturday, October 19, 2024 8:57:50 PM To: donaldzou/WGDashboard @.> Cc: Donald Zou @.>; Comment @.> Subject: Re: [donaldzou/WGDashboard] it just crashes, randomly (Issue #432)

Can we possibly have version that uses SQL or PostgreSQL, if it is for sure caused by SQLite

— Reply to this email directly, view it on GitHubhttps://github.com/donaldzou/WGDashboard/issues/432#issuecomment-2423834049, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUM7QR6RBDYBA53VA6TZ4JJM5AVCNFSM6AAAAABQHJNJAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRTHAZTIMBUHE. You are receiving this because you commented.Message ID: @.***>

donaldzou commented 1 week ago

Well we can be sure is something caused the error of SQLite.. but I haven’t seen this issue before... so maybe try to remove the whole database file and let WGDashboard to rebuild one and see if it still case?

Get Outlook for iOShttps://aka.ms/o0ukef


From: Donald Cheng Hong Zou @.> Sent: Saturday, October 19, 2024 9:00:19 PM To: donaldzou/WGDashboard @.>; donaldzou/WGDashboard @.> Cc: Comment @.> Subject: Re: [donaldzou/WGDashboard] it just crashes, randomly (Issue #432)

We could, but this will need to rewrite most of the SQL statements. The easiest way is to catch the error and prevent the dashboard to crash.

Get Outlook for iOShttps://aka.ms/o0ukef


From: reloadlife @.> Sent: Saturday, October 19, 2024 8:57:50 PM To: donaldzou/WGDashboard @.> Cc: Donald Zou @.>; Comment @.> Subject: Re: [donaldzou/WGDashboard] it just crashes, randomly (Issue #432)

Can we possibly have version that uses SQL or PostgreSQL, if it is for sure caused by SQLite

— Reply to this email directly, view it on GitHubhttps://github.com/donaldzou/WGDashboard/issues/432#issuecomment-2423834049, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUM7QR6RBDYBA53VA6TZ4JJM5AVCNFSM6AAAAABQHJNJAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRTHAZTIMBUHE. You are receiving this because you commented.Message ID: @.***>

reloadlife commented 1 week ago

yeah, i've already done it, and it still remains, i could contribute to fix the SQLStatements and convert them to support MySQL or PSQL.

using MySQL or PSQL is more stable overall.

reloadlife commented 1 week ago

for now, i'm going to add a try / catch to prevent the panel from crashing, please merge :)

reloadlife commented 1 week ago

even after the new patch, some times, it crashes and seems like it's whenever a new share link is created / expires, the crash happens.

-10-23 20:22:28,647] ERROR in app: Exception on /api/getWireguardConfigurationInfo [GET]
Traceback (most recent call last):
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask_cors/extension.py", line 194, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/WGDashboard/src/venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/opt/WGDashboard/src/dashboard.py", line 1922, in API_getConfigurationInfo
    "configurationPeers": WireguardConfigurations[configurationName].getPeersList(),
  File "/opt/WGDashboard/src/dashboard.py", line 909, in getPeersList
    self.__getPeers()
  File "/opt/WGDashboard/src/dashboard.py", line 678, in __getPeers
    self.Peers.append(Peer(i, self))
  File "/opt/WGDashboard/src/dashboard.py", line 963, in __init__
    self.getShareLink()
  File "/opt/WGDashboard/src/dashboard.py", line 1071, in getShareLink
    self.ShareLink = AllPeerShareLinks.getLink(self.configuration.Name, self.id)
  File "/opt/WGDashboard/src/dashboard.py", line 411, in getLink
    self.__getSharedLinks()
  File "/opt/WGDashboard/src/dashboard.py", line 406, in __getSharedLinks
    allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall()
  File "/opt/WGDashboard/src/dashboard.py", line 1425, in sqlSelect
    with sqldb:
sqlite3.DatabaseError: no more rows available
donaldzou commented 1 week ago

Just realized you're using Python 3.8.10 not Python 3.10? Maybe is because of this?

reloadlife commented 6 days ago

I am using 3.10 not 3.8, i thought i was using 3.8 when openning this issue, my bad on that part.

(i have 3.8 installed on the server, but the venv is using 3.10)

donaldzou commented 6 days ago

Are you running on a VM or a physical machine? If is a VM, maybe deploy a new Ubuntu and see if the issue still persist? I can't find anything about this issue lol..

reloadlife commented 4 days ago

it is on a VM, and i did try it on a new machine, it still happens ... i couldn't find anything about it either ...

donaldzou commented 4 days ago

How many cores, memory and storage did you assigned to your VM?