bramvreugd / Domoticz-KNMI-Weather-Plugin

Get the KNMI (Dutch) weather information
MIT License
2 stars 2 forks source link

Error: KNMI Weer: KNMI returned a status: 301 (new installation) #4

Closed Rylfas closed 2 months ago

Rylfas commented 2 months ago

Installed the KNMI weather plugin for the first time in Domoticz 2024.4

After installation: git clone https://github.com/bramvreugd/Domoticz-KNMI-Weather-Plugin.git and a Domoticz restart. The creation in the Hardware section: This error is occurs and is persistent.

2024-06-19 12:24:23.195 Amsterdam: onstart 2024-06-19 12:24:23.195 Amsterdam: mode 6:0 2024-06-19 12:24:23.195 Amsterdam: Name=HTTP Test, Transport=TCP/IP, Protocol=HTTP, Address=Amsterdam 2024-06-19 12:24:23.195 Amsterdam: Sending connect 2024-06-19 12:24:23.196 Amsterdam: Sended connect 2024-06-19 12:24:23.005 Status: Amsterdam: Entering work loop. 2024-06-19 12:24:23.005 Status: Amsterdam: Started. 2024-06-19 12:24:23.194 Status: Amsterdam: Initialized version 1.3.0, author 'Bramv' 2024-06-19 12:25:28.322 Amsterdam: onDisconnect called for connection to: weerlive.nl:80 2024-06-19 12:30:23.196 Error: Amsterdam: KNMI returned a status: 301 2024-06-19 12:31:28.168 Amsterdam: onDisconnect called for connection to: weerlive.nl:80

The API key is valid (tested). Second time installation as described in previous Issue was not successful. Python is version 3.9.2

Any ideas?

edwinp1 commented 2 months ago

Same error here

bramvreugd commented 2 months ago

Rylfas schreef op 2024-06-19 12:41:

Installed the KNMI weather plugin for the first time in Domoticz 2024.4

After installation: git clone https://github.com/bramvreugd/Domoticz-KNMI-Weather-Plugin.git and a Domoticz restart. The creation in the Hardware section: This error is occurs and is persistent.

2024-06-19 12:24:23.195 Amsterdam: onstart 2024-06-19 12:24:23.195 Amsterdam: mode 6:0 2024-06-19 12:24:23.195 Amsterdam: Name=HTTP Test, Transport=TCP/IP, Protocol=HTTP, Address=Amsterdam 2024-06-19 12:24:23.195 Amsterdam: Sending connect 2024-06-19 12:24:23.196 Amsterdam: Sended connect 2024-06-19 12:24:23.005 Status: Amsterdam: Entering work loop. 2024-06-19 12:24:23.005 Status: Amsterdam: Started. 2024-06-19 12:24:23.194 Status: Amsterdam: Initialized version 1.3.0, author 'Bramv' 2024-06-19 12:25:28.322 Amsterdam: onDisconnect called for connection to: weerlive.nl:80 2024-06-19 12:30:23.196 Error: Amsterdam: KNMI returned a status: 301 2024-06-19 12:31:28.168 Amsterdam: onDisconnect called for connection to: weerlive.nl:80

The API key is valid (tested). Second time installation as described in previous Issue was not successful. Python is version 3.9.2

Any ideas?

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Links:

[1] https://github.com/bramvreugd/Domoticz-KNMI-Weather-Plugin/issues/4 [2] https://github.com/notifications/unsubscribe-auth/AEAV657IPDBBLT5A3TMGF2TZIFN7PAVCNFSM6AAAAABJRZLD36VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DEMBRG4YDOMI

Hi Rylfas and Edwin,

Thanks for reporting. It stopped working on the 14th at my installation but after i restarted the plugin it worked again. Can you test the plugin again after disabeling and re-enabeling it again.

Can you also test the url directly in your browser http://weerlive.nl/api/weerlive_api_v2.php?key=your_key&locatie=Hoek%20van%20Holland

Replace your_key with your api key

kind regards, Bram

Rylfas commented 2 months ago

Hello Bram,

Problem remains after restart of the plugin.

The URL with my API key works without problems.

KInd regards,

Frank

edwinp1 commented 2 months ago

Hello Bram,

Problem remains after restart of the plugin. RPI reboot did not solve it either

Version: 2024.4 Build Hash: 731719420 Compile Date: 2024-01-30 09:16:34 dzVents Version: 3.1.8 Python Version: 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]

The URL with my API key works without problems.

KInd regards,

Edwin

edwinp1 commented 2 months ago

Hello Bram,

This is in my log when I have Debug on ALL Replaced my ket with @@@@ Hope this is helpfull

2024-06-24 23:01:20.090 KNMI: Received 494 bytes of data 2024-06-24 23:01:20.091 KNMI: 48 54 54 50 2f 31 2e 31 20 33 30 31 20 4d 6f 76 65 64 20 50 HTTP/1.1.301.Moved.P 2024-06-24 23:01:20.091 KNMI: 65 72 6d 61 6e 65 6e 74 6c 79 0d 0a 53 65 72 76 65 72 3a 20 ermanently..Server:. 2024-06-24 23:01:20.091 KNMI: 6e 67 69 6e 78 2f 31 2e 32 30 2e 31 0d 0a 44 61 74 65 3a 20 nginx/1.20.1..Date:. 2024-06-24 23:01:20.091 KNMI: 4d 6f 6e 2c 20 32 34 20 4a 75 6e 20 32 30 32 34 20 32 31 3a Mon,.24.Jun.2024.21: 2024-06-24 23:01:20.091 KNMI: 30 31 3a 32 30 20 47 4d 54 0d 0a 43 6f 6e 74 65 6e 74 2d 54 01:20.GMT..Content-T 2024-06-24 23:01:20.091 KNMI: 79 70 65 3a 20 74 65 78 74 2f 68 74 6d 6c 0d 0a 43 6f 6e 74 ype:.text/html..Cont 2024-06-24 23:01:20.091 KNMI: 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 31 36 39 0d 0a 43 6f 6e ent-Length:.169..Con 2024-06-24 23:01:20.091 KNMI: 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 0d nection:.keep-alive. 2024-06-24 23:01:20.091 KNMI: 0a 4c 6f 63 61 74 69 6f 6e 3a 20 68 74 74 70 73 3a 2f 2f 77 .Location:.https://w 2024-06-24 23:01:20.091 KNMI: 65 65 72 6c 69 76 65 2e 6e 6c 2f 61 70 69 2f 77 65 65 72 6c eerlive.nl/api/weerl 2024-06-24 23:01:20.091 KNMI: 69 76 65 5f 61 70 69 5f 76 32 2e 70 68 70 3f 6b 65 79 3d 64 ive_api_v2.php?key=@ 2024-06-24 23:01:20.091 KNMI: 66 33 63 36 30 38 33 66 34 26 6c 6f 63 61 74 69 65 3d 35 32 @@@@@@@@@&locatie=52 2024-06-24 23:01:20.091 KNMI: 2e 33 38 37 32 33 25 32 43 35 2e 32 38 32 38 39 0d 0a 45 78 .38723%2C5.28289..Ex 2024-06-24 23:01:20.091 KNMI: 70 69 72 65 73 3a 20 54 68 75 2c 20 30 31 20 4a 61 6e 20 31 pires:.Thu,.01.Jan.1 2024-06-24 23:01:20.091 KNMI: 39 37 30 20 30 30 3a 30 30 3a 30 31 20 47 4d 54 0d 0a 43 61 970.00:00:01.GMT..Ca 2024-06-24 23:01:20.091 KNMI: 63 68 65 2d 43 6f 6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63 68 che-Control:.no-cach 2024-06-24 23:01:20.091 KNMI: 65 0d 0a 0d 0a 3c 68 74 6d 6c 3e 0d 0a 3c 68 65 61 64 3e 3c e......< 2024-06-24 23:01:20.091 KNMI: 74 69 74 6c 65 3e 33 30 31 20 4d 6f 76 65 64 20 50 65 72 6d title>301.Moved.Perm 2024-06-24 23:01:20.091 KNMI: 61 6e 65 6e 74 6c 79 3c 2f 74 69 74 6c 65 3e 3c 2f 68 65 61 anently</hea 2024-06-24 23:01:20.091 KNMI: 64 3e 0d 0a 3c 62 6f 64 79 3e 0d 0a 3c 63 65 6e 74 65 72 3e d>....

2024-06-24 23:01:20.091 KNMI: 3c 68 31 3e 33 30 31 20 4d 6f 76 65 64 20 50 65 72 6d 61 6e

301.Moved.Perman 2024-06-24 23:01:20.091 KNMI: 65 6e 74 6c 79 3c 2f 68 31 3e 3c 2f 63 65 6e 74 65 72 3e 0d ently

. 2024-06-24 23:01:20.091 KNMI: 0a 3c 68 72 3e 3c 63 65 6e 74 65 72 3e 6e 67 69 6e 78 2f 31 .
nginx/1 2024-06-24 23:01:20.091 KNMI: 2e 32 30 2e 31 3c 2f 63 65 6e 74 65 72 3e 0d 0a 3c 2f 62 6f .20.1
..</bo 2024-06-24 23:01:20.091 KNMI: 64 79 3e 0d 0a 3c 2f 68 74 6d 6c 3e 0d 0a .. .. .. .. .. .. dy>.... 2024-06-24 23:01:20.091 KNMI: Pushing 'onMessageCallback' on to queue 2024-06-24 23:01:20.091 KNMI: Acquiring GIL for 'ReadEvent' 2024-06-24 23:01:20.091 KNMI: Processing 'onMessageCallback' message 2024-06-24 23:01:20.091 KNMI: Acquiring GIL for 'onMessageCallback' 2024-06-24 23:01:20.092 KNMI: Calling message handler 'onMessage' on 'module' type object. 2024-06-24 23:01:20.092 KNMI: Acquiring GIL for 'onMessageCallback' 2024-06-24 23:01:20.092 Error: KNMI: KNMI returned a status: 301 2024-06-24 23:01:39.027 KNMI: Pushing 'onHeartbeatCallback' on to queue 2024-06-24 23:01:39.077 KNMI: Processing 'onHeartbeatCallback' message 2024-06-24 23:01:39.077 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:01:39.078 KNMI: Calling message handler 'onHeartbeat' on 'module' type object. 2024-06-24 23:01:39.078 KNMI: onHeartbeat called, Connection is alive. 2024-06-24 23:01:39.078 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:01:59.018 KNMI: Pushing 'onHeartbeatCallback' on to queue 2024-06-24 23:01:59.068 KNMI: Processing 'onHeartbeatCallback' message 2024-06-24 23:01:59.068 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:01:59.068 KNMI: Calling message handler 'onHeartbeat' on 'module' type object. 2024-06-24 23:01:59.068 KNMI: onHeartbeat called, Connection is alive. 2024-06-24 23:01:59.068 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:02:18.138 KNMI: Pushing 'SettingsDirective' on to queue 2024-06-24 23:02:18.155 KNMI: Processing 'SettingsDirective' message 2024-06-24 23:02:18.155 KNMI: Acquiring GIL for 'SettingsDirective' 2024-06-24 23:02:18.158 KNMI: Acquiring GIL for 'SettingsDirective' 2024-06-24 23:02:19.010 KNMI: Pushing 'onHeartbeatCallback' on to queue 2024-06-24 23:02:19.060 KNMI: Processing 'onHeartbeatCallback' message 2024-06-24 23:02:19.060 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:02:19.060 KNMI: Calling message handler 'onHeartbeat' on 'module' type object. 2024-06-24 23:02:19.060 KNMI: onHeartbeat called, Connection is alive. 2024-06-24 23:02:19.060 KNMI: Acquiring GIL for 'onHeartbeatCallback' 2024-06-24 23:02:24.730 KNMI: Acquiring GIL for 'KNMI' 2024-06-24 23:02:24.730 KNMI: Pushing 'DisconnectDirective' on to queue 2024-06-24 23:02:24.730 KNMI: Processing 'DisconnectDirective' message 2024-06-24 23:02:24.730 KNMI: Acquiring GIL for 'DisconnectDirective' 2024-06-24 23:02:24.730 KNMI: Disconnect directive received for 'weerlive.nl:80'. 2024-06-24 23:02:24.730 KNMI: Handling TCP disconnect, socket (weerlive.nl:80) is connected 2024-06-24 23:02:24.730 KNMI: Acquiring GIL for 'CPluginTransportTCP::handleRead' 2024-06-24 23:02:24.730 KNMI: Acquiring GIL for 'DisconnectDirective' 2024-06-24 23:02:24.732 KNMI: Pushing 'DisconnectedEvent' on to queue 2024-06-24 23:02:24.732 KNMI: Processing 'DisconnectedEvent' message 2024-06-24 23:02:24.732 KNMI: Acquiring GIL for 'DisconnectedEvent' 2024-06-24 23:02:24.732 KNMI: Disconnect event received for 'weerlive.nl:80'. 2024-06-24 23:02:24.732 KNMI: Pushing 'onDisconnectCallback' on to queue 2024-06-24 23:02:24.732 KNMI: Pushing 'onStopCallback' on to queue 2024-06-24 23:02:24.732 KNMI: Acquiring GIL for 'DisconnectedEvent' 2024-06-24 23:02:24.732 KNMI: Processing 'onDisconnectCallback' message 2024-06-24 23:02:24.732 KNMI: Acquiring GIL for 'onDisconnectCallback' 2024-06-24 23:02:24.732 KNMI: Calling message handler 'onDisconnect' on 'module' type object. 2024-06-24 23:02:24.732 KNMI: onDisconnect called for connection to: weerlive.nl:80 2024-06-24 23:02:24.732 KNMI: Acquiring GIL for 'onDisconnectCallback' 2024-06-24 23:02:24.732 KNMI: Processing 'onStopCallback' message 2024-06-24 23:02:24.732 KNMI: Acquiring GIL for 'onStopCallback' 2024-06-24 23:02:24.732 KNMI: Calling message handler 'onStop' on 'module' type object. 2024-06-24 23:02:24.732 KNMI: onStop - Plugin is stopping. 2024-06-24 23:02:24.754 KNMI: Deallocating connection object 'KNMIConn' (weerlive.nl:80).

MPaans commented 2 months ago

The issue is that weerlive.nl is redirecting http to https. I fixed this by replacing everything "HTTP" with "HTTPS" (not sure if the hardcoded 'Protocol="HTTP"' bits is a conscious choice, or it should be using the self.sProtocol variable), and replacing sPort="80" with "443"

bramvreugd commented 2 months ago

Thank you for fixing ir. I was unable to fix it for the next week because I have no access to the system.

Op wo 26 jun. 2024 22:38 schreef Marcel Paans @.***>:

The issue is that weerlive.nl is redirecting http to https. I fixed this by replacing everything "HTTP" with "HTTPS" (not sure if the hardcoded 'Protocol="HTTP"' bits is a conscious choice, or it should be using the self.sProtocol variable), and replacing sPort="80" with "443"

— Reply to this email directly, view it on GitHub https://github.com/bramvreugd/Domoticz-KNMI-Weather-Plugin/issues/4#issuecomment-2192588740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEAV655HLEC2GLDX4ZD4VC3ZJMRERAVCNFSM6AAAAABJRZLD36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGU4DQNZUGA . You are receiving this because you commented.Message ID: @.***>

MPaans commented 2 months ago

Got a different issue now since last night, coincidentally when my internet connection went down for a while, so maybe this doesn't affect other people. Anyway, when I restart Domoticz it show this in the logs: Error: KNMI weather: Connection Exception: 'resolve: Host not found (non-authoritative), try again later [asio.netdb:2]' connecting to 'weerlive.nl:443'

And then when it tries to connect every 10 mins or so, it times out (not surprising if it can't find the host).. KNMI weather: Failed to connect (110) to: **********:********* with error: Connection timed out

I tried deleting the pycache/plugin.cpython-37.pyc file and rebooting my PI, but that didn't do anything.

Oddly enough, when using curl on my Domoticz PI host to retrieve the data from the API it has no issues. I'm not familiar with Python, but I googled "[asio.netdb:2]" and seems to indicate a deeper issue.

Edit: Correction, after the reboot, it keeps giving the first error message every 10mins: Error: KNMI weather: Connection Exception: 'resolve: Host not found (non-authoritative), try again later [asio.netdb:2]' connecting to 'weerlive.nl:443'

Edit 2: Tried out host weerlive.nl on a whim and it also failed with a timeout. Apparently the /etc/resolv.conf on my PI was a symlink to /run/systemd/resolve/resolv.conf that didn't exist anymore. Not quite sure how or why that happened, but I removed the symlink and put a file there with the correct settings. Thought I fixed it as host weerlive.nl returned with IP addresses. But alas, the plugin is now returning this again: KNMI weather: Failed to connect (110) to: **********:********* with error: Connection timed out

Edit 3: Problem solved itself. Getting data from weerlive.nl as of 19:00 today. 🤷🏻

Rylfas commented 2 months ago

The issue is that weerlive.nl is redirecting http to https. I fixed this by replacing everything "HTTP" with "HTTPS" (not sure if the hardcoded 'Protocol="HTTP"' bits is a conscious choice, or it should be using the self.sProtocol variable), and replacing sPort="80" with "443"

This solved my problem.

Thanks to both of you

edwinp1 commented 2 months ago

Can someone post the plugin.py the have working right now, please?

Do not know exactly if all http mentions need to be changed to https

Rylfas commented 2 months ago

Can someone post the plugin.py the have working right now, please?

Do not know exactly if all http mentions need to be changed to https

plugin.txt

You have to rename the plugin back to plugin.py to use it or use it as a reference.

edwinp1 commented 2 months ago

great thx

After-burner commented 2 months ago

It's a kind of Lourdes experience indeed. This HTTPS/443 solution worked for me too.

Thanks.