JanJaapKo / domoticz-GoodWeSEMS

Domoticz GoodWe Solar Inverter plugin (SEMS API)
http://www.domoticz.com/forum/viewtopic.php?f=65&t=28983
MIT License
6 stars 4 forks source link

Suddenly (last weeks) a lot of connection errors #17

Closed waltervl closed 2 years ago

waltervl commented 2 years ago

Lot of connection errors the last weeks Error: Goodwe Solar: RequestException: HTTPSConnectionPool(host='eu.semsportal.com', port=443): Read timed out. (read timeout=5)

You already mention this in the readme.

The PHP script does not seem to have this issue https://www.domoticz.com/forum/viewtopic.php?p=292043#p292043 so perhaps it could be possible to fix?

Running stable Domoticz 2022.1

JanJaapKo commented 2 years ago

I've been trying the API's in the php script using postman. They also take a long time to load, so it seems that there is an issue on Goodwe server side. In fact, (trying to) log in to semsportal.com also returns a message saying network error.......

Difference with the PHP script is that it doesn't time-out but waits forever for a response. This is in Domoticz not desired as the connection is not multithreaded, so it will block all of domoticz (or at least the plugin framework)......

waltervl commented 2 years ago

Python plugins support multihread, https://www.domoticz.com/wiki/Developing_a_Python_plugin#Sleeping_and_multi-threading_details : The Python Framework has been uplifted to support multi-threaded plugins, key points:

Use of asynchronous code or modules and callback functions are now supported. These should function as expected. All threads started within the plugin (either directly or by imported modules) must be terminated by the plugin prior to the plugin stopping ('onStop' is the recommended place for this). Failure to do this will result in Python aborting Domoticz during hardware 'Stops' &/or 'Updates'. The Plugin Framework cannot enumerate threads started by the plugin or stop them (Python limitation) and any active threads when the plugin interpreter is destroyed will cause Python to abort. YOU HAVE BEEN WARNED ! An example of a multi-threaded plugin including how to show running threads and thread shutdown can be found here on Github

JanJaapKo commented 2 years ago

Fair point. However this does not resolve the fact that the server simply isn't responding. So timing it out in 5 or 10 seconds is just an easy way out (no need for complicated multi threading in which I have no experience in Python), since if no response in 10 seconds, who knows how long it will take? Then my choice is to abort and try again after the set polling time (default 5 minutes). This should also free up resources on the server side as well.