Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RustDesk WebUi - HOME tab gives error 500 #161

Closed
Pofig1sT161 opened this issue Nov 21, 2024 · 8 comments
Closed

RustDesk WebUi - HOME tab gives error 500 #161

Pofig1sT161 opened this issue Nov 21, 2024 · 8 comments

Comments

@Pofig1sT161
Copy link

There were 500 errors related to the fact that the database was locked (on SQLite3) due to multiple calls to the database (I need this and it is used in another application in the same way, so SQLite3 is not suitable for me due to its limitations) otherwise the errors were minor ( I guess because of the special characters in the UUID - after processing this exception, the errors went away) - I switched the database to MYSQL (mysql Ver 8.0.40-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu)))
locking errors are gone, everything works except the HOME button (The page - which opens automatically after authorization in WEBUi) while all other pages and tabs work perfectly and without failures (including the admin panel)
Below are screenshots of the errors.
image
image
image
image

@Pofig1sT161
Copy link
Author

Code apiserver.error

Internal Server Error: /api/work
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/contrib/auth/decorators.py", line 60, in _view_wrapper
return view_func(request, *args, **kwargs)
File "/opt/rustdesk/rustdesk-api-server/api/views_front.py", line 247, in work
paginator = Paginator(get_all_info(), 1000) if show_type == 'admin' and u.is_admin else Paginator(get_single_info(u.id), 1000)
File "/opt/rustdesk/rustdesk-api-server/api/views_front.py", line 207, in get_single_info
peers[rid]['create_time'] = device.create_time.strftime('%Y-%m-%d')
KeyError: 'XXXXXXXX'
[21/Nov/2024 09:54:19] "GET /api/work HTTP/1.1" 500 81832

XXXXXXX - ID Client

@kingmo888
Copy link
Owner

peers[rid]['create_time'] = device.create_time.strftime('%Y-%m-%d')
peers is a dict, rid not in peers.

u can print something, eg peers.keys

@Pofig1sT161
Copy link
Author

tell me how to change the request?

@Pofig1sT161
Copy link
Author

Pofig1sT161 commented Nov 22, 2024

That's it, I solved the problem!

To do this I slightly modified the views_front.py code

def get_single_info(uid):
    peers = RustDeskPeer.objects.filter(Q(uid=uid))
    rids = [x.rid for x in peers]
    peers = {x.rid: model_to_dict(x) for x in peers}
    # print(peers)
    devices = RustDesDevice.objects.filter(rid__in=rids)
    devices = {x.rid: x for x in devices}
    now = datetime.datetime.now()
    for rid, device in devices.items():
        if rid not in peers:
            continue
        peers[rid]['create_time'] = device.create_time.strftime('%Y-%m-%d')
        peers[rid]['update_time'] = device.update_time.strftime('%Y-%m-%d %H:%M')
        peers[rid]['version'] = device.version
        peers[rid]['memory'] = device.memory
        peers[rid]['cpu'] = device.cpu
        peers[rid]['os'] = device.os
        peers[rid]['status'] = _('在线') if (now - device.update_time).seconds <= 120 else _('离线')

    for rid in peers.keys():
        peers[rid]['has_rhash'] = _('是') if len(peers[rid]['rhash']) > 1 else _('否')

    return [v for k, v in peers.items()]

@kingmo888
Copy link
Owner

cool!

@Pofig1sT161
Copy link
Author

Hmmmm, I analyzed the logs - I discovered that connection and file transfer logs are not written to the MYSQL table

`Internal Server Error: /api/audit/conn
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/mysql/base.py", line 76, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1048, "Column 'id' cannot be null")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/rustdesk/rustdesk-api-server/api/views_api.py", line 293, in audit
new_conn_log.save()
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 891, in save
self.save_base(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 997, in save_base
updated = self._save_table(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 1160, in _save_table
results = self._do_insert(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 1201, in _do_insert
return manager._insert(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 1847, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/sql/compiler.py", line 1836, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 122, in execute
return super().execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/mysql/base.py", line 81, in execute
raise IntegrityError(*tuple(e.args))
django.db.utils.IntegrityError: (1048, "Column 'id' cannot be null")
[22/Nov/2024 15:02:43] "POST /api/audit/conn HTTP/1.1" 500 132739`

`Internal Server Error: /api/audit/file
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/mysql/base.py", line 76, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.10/dist-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1048, "Column 'id' cannot be null")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/rustdesk/rustdesk-api-server/api/views_api.py", line 309, in audit
new_file_log.save()
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 891, in save
self.save_base(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 997, in save_base
updated = self._save_table(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 1160, in _save_table
results = self._do_insert(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/base.py", line 1201, in _do_insert
return manager._insert(
File "/usr/local/lib/python3.10/dist-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 1847, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/usr/local/lib/python3.10/dist-packages/django/db/models/sql/compiler.py", line 1836, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 122, in execute
return super().execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.10/dist-packages/django/db/backends/mysql/base.py", line 81, in execute
raise IntegrityError(*tuple(e.args))
django.db.utils.IntegrityError: (1048, "Column 'id' cannot be null")
[22/Nov/2024 15:17:03] "POST /api/audit/file HTTP/1.1" 500 132657`

@Pofig1sT161
Copy link
Author

That's it, I solved the problem!)))

To do this, I ran these commands in MYSQL

ALTER TABLE api_connlog CHANGE COLUMN id idINT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 123456; ALTER TABLE api_filelog CHANGE COLUMNid id INT(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 123456;

@kingmo888
Copy link
Owner

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants