2e3s / awatcher

Activity and idle watchers
Mozilla Public License 2.0
126 stars 4 forks source link

Can't get awatcher to run (ERROR aw_datastore::worker) #18

Closed forvard2 closed 4 months ago

forvard2 commented 4 months ago

I tried to run both as a module and as a bundle, but I always get the same error.

[2024-05-01 08:27:25.246565 WARN rocket::launch] šŸš€ Rocket has launched from http://127.0.0.1:5600
[2024-05-01 08:27:27.232318 ERROR aw_datastore::worker] DB worker quitting, error: RecvError
Error: Failed to create bucket aw-watcher-afk_fedora

Caused by:
    0: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
    1: error trying to connect: tcp connect error: Connection refused (os error 111)
    2: tcp connect error: Connection refused (os error 111)
    3: Connection refused (os error 111)
2e3s commented 4 months ago

Failed to create bucket aw-watcher-afk_fedora 0: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)

This is the problem, but I'm not sure why it can happen if the server gets running at :5600 as your output suggests. Could you run this with -vvvv to have a bit more logs?

forvard2 commented 4 months ago

Here are the logs when I run awatcher as a module for aw-qt:

2024-05-02 09:54:28 [INFO ]: Started aw-qt...  (aw_qt.main:53)
2024-05-02 09:54:28 [WARNING]: Found matching file but was not executable: /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-qt.desktop  (aw_qt.manager:64)
2024-05-02 09:54:28 [WARNING]: Found matching file but was not executable: /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-server-rust/aw-server.service  (aw_qt.manager:64)
2024-05-02 09:54:28 [INFO ]: Found 4 bundled modules  (aw_qt.manager:85)
2024-05-02 09:54:28 [DEBUG]:  - aw-watcher-afk at /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-watcher-afk/aw-watcher-afk  (aw_qt.manager:24)
2024-05-02 09:54:28 [DEBUG]:  - aw-server-rust at /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-server-rust/aw-server-rust  (aw_qt.manager:24)
2024-05-02 09:54:28 [DEBUG]:  - aw-watcher-window at /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-watcher-window/aw-watcher-window  (aw_qt.manager:24)
2024-05-02 09:54:28 [DEBUG]:  - aw-server at /home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-server/aw-server  (aw_qt.manager:24)
2024-05-02 09:54:28 [INFO ]: Found 1 system modules  (aw_qt.manager:119)
2024-05-02 09:54:28 [DEBUG]:  - aw-awatcher at /usr/local/bin/aw-awatcher  (aw_qt.manager:24)
2024-05-02 09:54:28 [INFO ]: Starting module aw-server-rust  (aw_qt.manager:148)
2024-05-02 09:54:28 [INFO ]: Starting module aw-awatcher  (aw_qt.manager:148)
[2024-05-02 09:54:28][INFO][aw_server]: Using DB at path "/home/nett/.local/share/activitywatch/aw-server-rust/sqlite.db"
[2024-05-02 09:54:28][INFO][aw_server]: Cannot find assets "./aw-webui/dist/"
[2024-05-02 09:54:28][INFO][aw_server]: Using aw-webui assets at path "/home/nett/Downloads/Awatch/activitywatch-v0.12.2-linux-x86_64/activitywatch/aw-server-rust/./static/"
[2024-05-02 09:54:28][INFO][aw_server::endpoints]: Starting aw-server-rust at 127.0.0.1:5600
2024-05-02 09:54:28 [INFO ]: Creating trayicon...  (aw_qt.trayicon:206)
2024-05-02 09:54:28 [INFO ]: Initialized aw-qt and trayicon successfully  (aw_qt.trayicon:262)
Error: Failed to create bucket aw-watcher-afk_fedora

Caused by:
    0: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
    1: error trying to connect: tcp connect error: Connection refused (os error 111)
    2: tcp connect error: Connection refused (os error 111)
    3: Connection refused (os error 111)
qt.qpa.wayland: EGL not available
2024-05-02 09:54:30 [WARNING]: Tried to stop module aw-awatcher, but it wasn't running  (aw_qt.manager:185)

And here's the logs when I run the bundle

[2024-05-02 02:08:53.890868 INFO awatcher] Sending to server localhost:5600
[2024-05-02 02:08:53.890888 INFO awatcher] Idle timeout: 180 seconds
[2024-05-02 02:08:53.890893 INFO awatcher] Idle polling period: 5 seconds
[2024-05-02 02:08:53.890898 INFO awatcher] Window polling period: 1 seconds
[2024-05-02 02:08:53.900278 DEBUG awatcher::bundle::modules] Processing bundle config at /home/nett/.config/awatcher/bundle-config.toml
[2024-05-02 02:08:53.916669 WARN rocket::launch] šŸš€ Rocket has launched from http://127.0.0.1:5600
[2024-05-02 02:08:53.916831 WARN watchers::report_client] Failed to connect, retrying: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
[2024-05-02 02:08:53.917030 WARN watchers::report_client] Failed to connect, retrying: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
[2024-05-02 02:08:54.901618 WARN watchers::report_client] Failed to connect, retrying: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
[2024-05-02 02:08:55.903082 ERROR aw_datastore::worker] DB worker quitting, error: RecvError
Error: Failed to create bucket aw-watcher-afk_fedora

Caused by:
    0: error sending request for url (http://localhost:5600/api/0/buckets/aw-watcher-afk_fedora): error trying to connect: tcp connect error: Connection refused (os error 111)
    1: error trying to connect: tcp connect error: Connection refused (os error 111)
    2: tcp connect error: Connection refused (os error 111)
    3: Connection refused (os error 111)

If I run awatcher -vvvv --no-server, it seems to work

[2024-05-02 02:10:44.786433 WARN awatcher] Not sending to server localhost:5600
[2024-05-02 02:10:44.786454 INFO awatcher] Idle timeout: 180 seconds
[2024-05-02 02:10:44.786461 INFO awatcher] Idle polling period: 5 seconds
[2024-05-02 02:10:44.786467 INFO awatcher] Window polling period: 1 seconds
[2024-05-02 02:10:44.796017 DEBUG awatcher::bundle::modules] Processing bundle config at /home/nett/.config/awatcher/bundle-config.toml
[2024-05-02 02:10:44.812767 WARN rocket::launch] šŸš€ Rocket has launched from http://127.0.0.1:5600
[2024-05-02 02:10:44.818057 DEBUG watchers::watchers] Watcher "Wayland idle (ext-idle-notify-v1)" cannot run: the requested global was not found in the registry
[2024-05-02 02:10:44.826360 DEBUG watchers::watchers] Watcher "Wayland idle (KDE)" cannot run: the requested global was not found in the registry
[2024-05-02 02:10:44.827500 DEBUG watchers::watchers] Watcher "X11 idle (screensaver)" cannot run: Unsupported extension
[2024-05-02 02:10:44.827515 DEBUG watchers::watchers::gnome_wayland] Gnome Wayland detected
[2024-05-02 02:10:44.829384 DEBUG watchers::watchers] Watcher "Wayland window (wlr-foreign-toplevel-management-unstable-v1)" cannot run: the requested global was not found in the registry
[2024-05-02 02:10:44.830169 DEBUG watchers::watchers] Watcher "KWin window (script)" cannot run: org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable
[2024-05-02 02:10:44.830716 DEBUG watchers::watchers] Watcher "X11 window" cannot run: GetPropertyReply[_NET_WM_NAME] failed
[2024-05-02 02:10:44.830726 DEBUG watchers::watchers::gnome_wayland] Gnome Wayland detected
[2024-05-02 02:10:44.833223 INFO watchers::watchers] Selected watcher: Gnome idle (Mutter/IdleMonitor)
[2024-05-02 02:10:44.833230 INFO watchers::watchers] Starting idle watcher
[2024-05-02 02:10:44.833980 TRACE watchers::watchers::idle] Reporting as not idle
[2024-05-02 02:10:44.834141 INFO watchers::watchers] Selected watcher: Gnome window (extension)
[2024-05-02 02:10:44.834148 INFO watchers::watchers] Starting active window watcher
[2024-05-02 02:10:44.836232 DEBUG watchers::watchers::gnome_window] Changed window app_id="gnome-terminal-server", title="nett@fedora:~/Downloads/awatcher-bundle ā€” ./awatcher -vvvv"
[2024-05-02 02:10:44.836238 TRACE watchers::report_client] Reporting app_id: gnome-terminal-server, title: nett@fedora:~/Downloads/Awatch/awatcher-bundle ā€” ./awatcher -vvvv
[2024-05-02 02:10:45.839905 DEBUG watchers::watchers::gnome_window] Changed window app_id="gnome-terminal-server", title="nett@fedora:~/Downloads/awatcher-bundle ā€” ./awatcher -vvvv --no-server"
[2024-05-02 02:10:45.839930 TRACE watchers::report_client] Reporting app_id: gnome-terminal-server, title: nett@fedora:~/Downloads/Awatch/awatcher-bundle ā€” ./awatcher -vvvv --no-server
[2024-05-02 02:10:46.842520 TRACE watchers::report_client] Reporting app_id: gnome-terminal-server, title: nett@fedora:~/Downloads/Awatch/awatcher-bundle ā€” ./awatcher -vvvv --no-server
2e3s commented 4 months ago

Could it be some security settings, like a paranoiac firewall which doesn't let you connect even to localhost? E.g. when you run activitywatch with aw-qt, can you run other modules (builtin) than aw-awatcher? Can you get a response by executing curl http://127.0.0.1:5600 in terminal? If yes, can you get the response with curl when running awatcher -vvvv --no-server?

forvard2 commented 4 months ago

aw-qt works correctly with these modules ["aw-server-rust", "aw-watcher-afk", "aw-watcher-window"] When I run awatcher -vvvvvv --no-serverand run curl http://127.0.0.1:5600 I get this response:

<!doctype html><html><head><meta charset="utf-8"><title>ActivityWatch</title><!--[if IE]><link rel="icon" type="image/png" href="/static/logo.png"><![endif]--><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'self' 127.0.0.1:5600 127.0.0.1:5666 localhost:5666 *:27180 ws://*:27180 https://api.github.com/repos/ActivityWatch/activitywatch/releases/latest; img-src 'self' data:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; object-src 'none'; script-src 'self' 'unsafe-eval'"><script defer="defer" src="/js/chunk-vendors.906b2183.js"></script><script defer="defer" src="/js/index.3d24bd44.js"></script><link href="/css/chunk-vendors.82a142ae.css" rel="stylesheet"><link href="/css/index.442e69e5.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/static/logo.png"><link rel="icon" type="image/png" sizes="16x16" href="/static/logo.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="ActivityWatch"><link rel="apple-touch-icon" href="/static/logo.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="/static/logo.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but the ActivityWatch Web UI doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

2e3s commented 4 months ago

Okay, thanks. To be honest, I don't even have hypotheses to ask about, it seems very illogical that a thread cannot connect to a seemingly normally running another thread by HTTP. Maybe the server fails after the connection attempt, but it works for other people. I will try to install your exact environment and check if this is reproducible, but no promises and it's a second priority after another long due task #12 :pensive:

2e3s commented 4 months ago

By the way, does your localhost resolve to 127.0.0.1? nslookup localhost

forvard2 commented 4 months ago

By the way, does your localhost resolve to 127.0.0.1? nslookup localhost

that's where the problem was. my hosts looked like this

127.0.0.1 beta.ethereumwallet.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

It seems when I installed one of the wallets, it changed the host file. It's all working now!

2e3s commented 4 months ago

Wow, imagine the potential security leak with manipulations of hosts file. I will change connecting localhost to 127.0.0.1 explicitly to avoid it.