WebServer:8080 thread seems to have ended unexpectedly

Python and python framework

Moderator: leecollings

Post Reply
boggiz
Posts: 46
Joined: Thursday 07 March 2019 11:40
Target OS: NAS (Synology & others)
Domoticz version: 2024.4
Location: France
Contact:

WebServer:8080 thread seems to have ended unexpectedly

Post by boggiz »

Hello,
I currently upgraded from 2023.1 to 2024.4 because problems with Python & Paho MQTT.
Some of them are resolved but not this one :

Code: Select all

import sys
sys.path.append('/usr/local/lib/python3.9/dist-packages/')
import DomoticzEvents as DE # voir https://www.domoticz.com/wiki/Python_Events
import requests # https://fr.python-requests.org/en/latest/user/quickstart.html
from requests.auth import HTTPBasicAuth
from paho.mqtt import client as mqtt

Broker = "192.168.0.45"
PortaBroker = 11883
KeepAliveBroker = 60
clientID = "Boggiz"

CodePG = DE.user_variables["NewCodePG"]

if DE.changed_device_name == "Test Python" and DE.Devices["Test Python"].n_value_string == "On":
client = mqtt.Client(clientID) #create new instance

rc= client.connect(Broker,PortaBroker,KeepAliveBroker) #connect to broker
if  rc != 0: print("[E-STATUS] Connection au Broker. Resultat de la Connection: " + str(rc))

if CodePG == '' : CodePG = 'Re-Init'  # si ESP recoit ce message il renverra un nouveau code sans ouvrir la porte!

client.publish("home/domoticz/PG/Dz2PG", CodePG, qos=0, retain=False)    #publish message

# initialisation de la User Variable avant reception du nouveau code
url= "http://192.168.0.45:18080/json.htm?type=command&param=updateuservariable&vname=NewCodePG&vtype=string&vvalue=" 
CLE64 = {"Authorization" : "Basic RG9tb0JvZ2dpejpEUyFhZnMhYWZ5MTk1MA=="}
rc = requests.get(url, headers= CLE64)
if rc != 0: print("[E-INIT User Variable] erreur: " + str(rc))
This code works fine, the user variable is correctly initialized but a minute later, Domoticz froze with the error above (title).
An idea ?
NAS Syno DS718+ with 12Go ram
RFXtrx433XL v1044 with 3dBi antenna
Domoticz 2024.4 on Docker
TFA rain gauge, 4 ways automatic watering program, LINKY consumption, waterflow counter
boggiz
Posts: 46
Joined: Thursday 07 March 2019 11:40
Target OS: NAS (Synology & others)
Domoticz version: 2024.4
Location: France
Contact:

Re: WebServer:8080 thread seems to have ended unexpectedly

Post by boggiz »

Hello all,
I am partially answering myself.
By adding 'timeout=5' in requests.get Domoticz no longer crashes but I have a long list of errors in the log:

Code: Select all

2024-05-10 11:07:23.092 Error: Traceback (most recent call last):
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 536, in _make_request
2024-05-10 11:07:23.092 Error: response = conn.getresponse()
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 461, in getresponse
2024-05-10 11:07:23.092 Error: httplib_response = super().getresponse()
2024-05-10 11:07:23.092 Error: File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
2024-05-10 11:07:23.092 Error: response.begin()
2024-05-10 11:07:23.092 Error: File "/usr/lib/python3.9/http/client.py", line 307, in begin
2024-05-10 11:07:23.092 Error: version, status, reason = self._read_status()
2024-05-10 11:07:23.092 Error: File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
2024-05 -10 11:07:23.092 Error: line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
2024-05-10 11:07:23.092 Error: File "/usr/lib/python3.9/socket.py", line 704, in readinto
2024-05-10 11:07:23.092 Error: return self._sock.recv_into(b)
2024-05-10 11:07:23.092 Error: socket.timeout: timed out
2024-05-10 11:07:23.092 Error: 
2024-05-10 11:07:23.092 Error: The above exception was the direct cause of the following exception:
2024-05-10 11:07:23.092 Error: 
2024-05-10 11:07:23.092 Error: Traceback (most recent call last):
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 486, in send
2024-05-10 11:07:23.092 Error: resp = conn.urlopen(
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 844, in urlopen
2024-05-10 11:07:23.092 Error: retries = retries.increment(
2024-05-10 11:07:23.092 Error: File "/usr/local/li b/python3.9/dist-packages/urllib3/util/retry.py", lin e 470, in increment
2024-05-10 11:07:23.092 Error: raise reraise(type(error), error, _stacktrace)
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/util/util.py", line 39, in reraise
2024-05-10 11:07:23.092 Error: raise value
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 790, in urlopen
2024-05-10 11:07:23.092 Error: response = self._make_request(
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 538, in _make_request
2024-05-10 11:07:23.092 Error: self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 370, in _raise_timeout
2024-05-10 11:07:23.092 Error: raise ReadTimeoutError(
2024-05-10 11:07:23.092 Error: urllib3.exceptions.ReadTimeoutError: HT TPConnectionPool(host='192.168.0.45', port=18080): Read timed out. (read timeout=3)
2024-05-10 11:07:23.092 Error: 
2024-05-10 11:07:23.092 Error: During handling of the above exception, another exception occurred:
2024-05-10 11:07:23.092 Error: 
2024-05-10 11:07:23.092 Error: Traceback (most recent call last):
2024-05-10 11:07:23.092 Error: File "MQTTpublishPG.py", line 45, in 
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 73, in get
2024-05-10 11:07:23.092 Error: return request("get", url, params=params, **kwargs)
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 59, in request
2024-05-10 11:07:23.092 Error: return session.request(method=method, url=url, **kwargs)
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 589, in request
2024-05-10 11:07:23.092 Error: resp = self.send(prep, **send_kwargs)
2024-05-1 0 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 703, in send
2024-05-10 11:07:23.092 Error: r = adapter.send(request, **kwargs)
2024-05-10 11:07:23.092 Error: File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 532, in send
2024-05-10 11:07:23.092 Error: raise ReadTimeout(e, request=request)
2024-05-10 11:07:23.092 Error: requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.0.45', port=18080): Read timed out. (read timeout=3)
How to avoid these errors ?
NAS Syno DS718+ with 12Go ram
RFXtrx433XL v1044 with 3dBi antenna
Domoticz 2024.4 on Docker
TFA rain gauge, 4 ways automatic watering program, LINKY consumption, waterflow counter
boggiz
Posts: 46
Joined: Thursday 07 March 2019 11:40
Target OS: NAS (Synology & others)
Domoticz version: 2024.4
Location: France
Contact:

Re: WebServer:8080 thread seems to have ended unexpectedly

Post by boggiz »

... it's very easy with TRY exceptions !
NAS Syno DS718+ with 12Go ram
RFXtrx433XL v1044 with 3dBi antenna
Domoticz 2024.4 on Docker
TFA rain gauge, 4 ways automatic watering program, LINKY consumption, waterflow counter
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest