Closed jangrewe closed 2 years ago
Hey, it should work without putting the API key in quotes.
To verify that the config/API key is used can you restart the service and post the new log here?
By default the companion should log the config file location it read and the connection tries + used API key.
The logs are located in tmp/mobileraker.log
Okay, this is strange... i restarted all services involved, and now it seems to be able to connect, but without using the API key.
I also got no push notification, yet.
Edit: starting a print got me a notification, additional log lines appended
2022-07-13 10:04:55,645 [mobileraker.py:info()] - [Voron_2.4] Trying to connect to: ws://127.0.0.1:7125/websocket api key <NO API KEY>
2022-07-13 10:04:55,696 [mobileraker.py:info()] - [Voron_2.4] WebSocket connected
2022-07-13 10:04:55,697 [mobileraker.py:info()] - [Voron_2.4] Fetching printer Objects Try#0
2022-07-13 10:04:55,700 [mobileraker.py:info()] - [Voron_2.4] Received Server Info
2022-07-13 10:04:55,701 [mobileraker.py:info()] - [Voron_2.4] Querying printer Objects
2022-07-13 10:04:55,884 [mobileraker.py:info()] - [Voron_2.4] print_state transition NONE -> standby
2022-07-13 10:04:55,885 [mobileraker.py:info()] - [Voron_2.4] Subscribing to printer Objects
2022-07-13 10:04:55,896 [mobileraker.py:info()] - [Voron_2.4] Sending to firebase fcm (https://mobileraker.eliteschw31n.de): {'printState': 'standby', 'tokens': ['<redacted>'], 'printerIdentifier': 'e43cb7d3-<redacted>'
2022-07-13 10:13:53,756 [mobileraker.py:info()] - [Voron_2.4] print_state transition standby -> printing
2022-07-13 10:13:53,783 [mobileraker.py:info()] - [Voron_2.4] Sending to firebase fcm (https://mobileraker.eliteschw31n.de): {'printState': 'printing', 'tokens': ['<redacted>'], 'printerIdentifier': 'e43cb7d3-<redacted>, 'filename': 'Calibration cube.gcode', 'progress': 0.0052528645894942706, 'printingDuration': 0.0}
Not sure why it didn't work last night, because the config and its location is unchanged (besides removing the quotes around the API key again, but that's what i had initially). But it's working, that already a big win! :-)
That's weired. Did you setup a trusted client alongside enforcing logins?
Regarding the notifications, you need to open the app once after a restart and you will only receive notifications if mobileraker isn't in foreground. On Android the app can also be force closed after opening it once while on iOs it is required that mobileraker is in background. Sometimes the power saving constraints of iOS still manage to block the notifications.
Yes, 127.0.0.1 is in the trusted clients, but that shouldn't matter because of both force_logins: True
and an existing user - which, according to the moonraker docs, disables trusted clients?
Regarding the notifications: thanks, that part is working now! <3
It should disable the trusted_clients. However, it seems like your moonraker instance is using the trusted_clients instead of the users/api-key. I just tested the setup on my printer and everything works as expected however I am currently using moonraker : v0.7.1-589-g4bed314
Yea, it does look like it, though that's quite unexpected behaviour. Any other clients that are also listed in trusted_clients are indeed required to provide the API key. Maybe it's also a hardcoded behaviour explicitly and exclusively for 127.0.0.1
?
My moonraker version is v0.7.1-597-gd37f91c
, so a tiny bit newer.
Yea, it does look like it, though that's quite unexpected behaviour. Any other clients that are also listed in trusted_clients are indeed required to provide the API key. Maybe it's also a hardcoded behaviour explicitly and exclusively for
127.0.0.1
? My moonraker version isv0.7.1-597-gd37f91c
, so a tiny bit newer.
I had a chat with Arksine last week and he confirmed to me that localhost does not have any privileges and therefore I need to provide the API key.
Well, then something is wrong. I am providing an API key, mobileraker_companion says it is not using it, yet still it works! :-D
Well, then something is wrong. I am providing an API key, mobileraker_companion says it is not using it, yet still it works! :-D
Can you update the companion? The logging was setup wrongly. Now it should actually show you that it is using an API key :stuck_out_tongue_winking_eye:
Ah, that would explain it! Yes, now it works as expected:
2022-07-13 12:23:40,258 [mobileraker.py:info()] - [Voron_2.4] Trying to connect to: ws://127.0.0.1:7125/websocket api key <redacted>##########################
I'm one of those people that have set
force_logins: True
, but the API key i'm giving to mobileraker_companion doesn't seem to work. I've tried in~/klipper_config/Mobileraker.conf
and~/mobileraker_companion/Mobileraker.conf
, with the key both raw and quoted, yet still i get a 401:My
~/klipper_config/Mobileraker.conf
looks like this:The API key definitely works: