Problème démon python

Bonjour,

Je suis en train de créer mon plugin et j’ai un problème avec le démon en python, j’appel une bibliothèque tierce dans mon démon, cette bibliothèque permet de dialoguer en SOAP avec un contrôleur domotique IHC. Dans cette bibliothèque j’appel une fonction sous forme de thread qui envoi une requête SOAP en long polling au contrôleur toute les 10 secondes. Lorsque la connexion ip est rompue le programme est censé détecter le problème au bout de 2minutes et tenter une nouvelle authentification toutes les 45secondes. Sauf que cela ne fonctionne pas, si je lance mon programme python directement sur mon PC windows le programme fonctionne parfaitement, mais sur jeedom il ne détecte pas la coupure de réseau ni le rétablissement et je suis obligé de relancer mon démon pour que ça reparte. Sur mon PC j’utilise python 3.9, dans les dépendances de mon plugin j’installe python3 mais je ne suis pas sûr que mon plugin utilise python 3 au final. Si je lance la commande python -v sur la jeedom ça me dis que la version est python 2.7. Je ne sais pas si le problème vient de là ou pas… Si quelqu’un a une idée d’où peux venir ce problème SVP

Le code du plugin est disponible ici : https://github.com/idhe-dev/ihc

D’avance merci,

Salut,

Tu dois avoir les 2 versions de python d’installées normalement.

Essayes :

python3 -v

Effectivement la version utilisée par défaut est la 2.7, il faut donc spécifier d’exécuter tes scripts en python3.

Merci pour ta réponse @Salvialf, en effet lorsque je lance la commande python3 -v j’ai une version python3.7.

Comment spécifier d’utiliser python 3 pour l’exécution des scripts ?

#! /usr/bin/env python3

Lorsque je lance mon démon c’est déjà spécifié python3 donc normalement mon démon s’exécute en python3 non ?

public static function deamon_start() {
		self::deamon_stop();
		$deamon_info = self::deamon_info();
		if ($deamon_info['launchable'] != 'ok') {
			throw new Exception(__('Veuillez vérifier la configuration', __FILE__));
		}

		$path = realpath(dirname(__FILE__) . '/../../resources/ihc');
		$cmd = 'sudo python3 ' . $path . '/ihc.py';
		$cmd .= ' --loglevel ' . log::convertLogLevel(log::getLogLevel(__CLASS__));
		$cmd .= ' --socketport ' . config::byKey('socketport', __CLASS__, '55099');
		$cmd .= ' --callback ' . network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/ihc/core/php/deamonIHC.php';
		$cmd .= ' --controllerID "' . trim(str_replace('"', '\"', config::byKey('controllerID', __CLASS__))) . '"';
		$cmd .= ' --controllerPW "' . trim(str_replace('"', '\"', config::byKey('controllerPW', __CLASS__))) . '"';
		$cmd .= ' --controllerIP "' . trim(str_replace('"', '\"', config::byKey('controllerIP', __CLASS__))) . '"';
		$cmd .= ' --apikey ' . jeedom::getApiKey(__CLASS__);
		$cmd .= ' --pid ' . jeedom::getTmpFolder(__CLASS__) . '/deamon.pid';
		log::add(__CLASS__, 'info', 'Lancement démon IHC');
		$result = exec($cmd . ' >> ' . log::getPathToLog('ihc_daemon') . ' 2>&1 &');
		$i = 0;
		while ($i < 20) {
			$deamon_info = self::deamon_info();
			if ($deamon_info['state'] == 'ok') {
				ihc::ihcNotify();
				break;
			}
			sleep(1);
			$i++;
		}
		if ($i >= 30) {
			log::add(__CLASS__, 'error', __('Impossible de lancer le démon IHC, vérifiez le log',__FILE__), 'unableStartDeamon');
			return false;
		}
		message::removeAll(__CLASS__, 'unableStartDeamon');
		return true;
	}

Le problème pour mon thread viendrait donc d’un autre problème ? Il faut que j’ajoute la ligne
#! /usr/bin/env python3 en haut de chaque fichiers python ??

Ben si dans un bash tu fait
python3 fichier.py
ce n’est pas indispensable
si tu fait
./fichier.py
en considérant qu’il a des droits executable
la oui il te faut la ligne !

Ok j’ai ajouté cette ligne en haut de chaque fichiers python de mon démon, mais j’ai toujours le même problème dans mon thread, donc ça ne vient pas de là…

Pas d’idée qui expliquerai ma problématique ?

Salut,
Il faudrait un log surtout.
Si lancé avec python3 alors tout est en python3 (3.7 ici) donc le problème n’est pas là (sauf s’il y a une dépendance qui demande 3.8 ou plus).

Voici les logs du démon, je n’ai pas l’impression qu’il y ait grand chose d’intéressant…

[2021-04-14 07:31:00.200][INFO] : Start daemon
[2021-04-14 07:31:00.200][INFO] : Log level : debug
[2021-04-14 07:31:00.200][DEBUG] : Socket port : 55099
[2021-04-14 07:31:00.201][DEBUG] : PID file : /tmp/jeedom/ihc/deamon.pid
[2021-04-14 07:31:00.201][DEBUG] : User : admin
[2021-04-14 07:31:00.201][DEBUG] : Controller IP : 192.168.1.8
[2021-04-14 07:31:00.209][DEBUG] : Starting new HTTP connection (1): 192.168.1.8:80
[2021-04-14 07:31:00.247][DEBUG] : http://192.168.1.8:80 "GET /wsdl/controller.wsdl HTTP/1.1" 200 14925
[2021-04-14 07:31:00.254][DEBUG] : Starting new HTTP connection (1): 192.168.1.8:80
[2021-04-14 07:31:00.398][DEBUG] : http://192.168.1.8:80 "POST /ws/AuthenticationService HTTP/1.1" 200 2155
[2021-04-14 07:31:00.402][INFO] : Authenticate succeeded
[2021-04-14 07:31:00.402][DEBUG] : Writing PID 29110 to /tmp/jeedom/ihc/deamon.pid
[2021-04-14 07:31:00.404][DEBUG] : Init request module v2.21.0
[2021-04-14 07:31:00.405][DEBUG] : Start listening
[2021-04-14 07:31:00.406][DEBUG] : Socket interface started
[2021-04-14 07:31:00.407][DEBUG] : LoopNetServer Thread started
[2021-04-14 07:31:00.408][DEBUG] : Listening on: [localhost:55099]
[2021-04-14 07:31:00.637][DEBUG] : Client connected to [127.0.0.1:50276]
[2021-04-14 07:31:00.638][DEBUG] : Message read from socket: b'{"method":"IHC_Notify","resids":[{"id":"102","ResourceID":3661842},{"id":"51","ResourceID":1140498},{"id":"54","ResourceID":3768594},{"id":"75","ResourceID":2944274},{"id":"84","ResourceID":3168786},{"id":"81","ResourceID":3136786},{"id":"78","ResourceID":3040018},{"id":"66","ResourceID":1408786},{"id":"69","ResourceID":4784402},{"id":"39","ResourceID":4537874},{"id":"45","ResourceID":4607506},{"id":"42","ResourceID":4572690},{"id":"96","ResourceID":4896786},{"id":"99","ResourceID":4904722},{"id":"30","ResourceID":835858},{"id":"28","ResourceID":4283921},{"id":"57","ResourceID":2080018},{"id":"63","ResourceID":4088850},{"id":"60","ResourceID":3364626},{"id":"90","ResourceID":4861970},{"id":"87","ResourceID":1945874},{"id":"234","ResourceID":1140498},{"id":"237","ResourceID":58203},{"id":"105","ResourceID":2417938},{"id":"108","ResourceID":4965138},{"id":"111","ResourceID":4997138},{"id":"36","ResourceID":1105938},{"id":"33","ResourceID":969490},{"id":"48","ResourceID":4643858},{"id":"93","ResourceID":2013202},{"id":"72","ResourceID":4125970}]}'
[2021-04-14 07:31:00.638][DEBUG] : Client disconnected from [127.0.0.1:50276]
[2021-04-14 07:31:00.641][DEBUG] : Message received in socket JEEDOM_SOCKET_MESSAGE
[2021-04-14 07:31:00.647][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:00.734][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 454
[2021-04-14 07:31:00.741][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:00.832][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 751
[2021-04-14 07:31:00.836][INFO] : Resource change 3661842->False
[2021-04-14 07:31:00.837][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3661842', 'Value': 'False'}
[2021-04-14 07:31:00.842][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:00.846][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:00.892][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:00.998][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 454
[2021-04-14 07:31:01.005][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:01.311][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 10246
[2021-04-14 07:31:01.319][INFO] : Resource change 1140498->True
[2021-04-14 07:31:01.320][INFO] : Resource change 1140498->True
[2021-04-14 07:31:01.320][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '1140498', 'Value': 'True'}
[2021-04-14 07:31:01.321][INFO] : Resource change 3768594->False
[2021-04-14 07:31:01.325][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.326][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '1140498', 'Value': 'True'}
[2021-04-14 07:31:01.326][INFO] : Resource change 2944274->False
[2021-04-14 07:31:01.334][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.334][INFO] : Resource change 3168786->False
[2021-04-14 07:31:01.335][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3768594', 'Value': 'False'}
[2021-04-14 07:31:01.336][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '2944274', 'Value': 'False'}
[2021-04-14 07:31:01.337][INFO] : Resource change 3136786->False
[2021-04-14 07:31:01.345][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.351][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.352][INFO] : Resource change 3040018->False
[2021-04-14 07:31:01.358][INFO] : Resource change 1408786->False
[2021-04-14 07:31:01.364][INFO] : Resource change 4784402->False
[2021-04-14 07:31:01.353][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3168786', 'Value': 'False'}
[2021-04-14 07:31:01.360][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3040018', 'Value': 'False'}
[2021-04-14 07:31:01.354][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3136786', 'Value': 'False'}
[2021-04-14 07:31:01.373][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.365][INFO] : Resource change 4537874->False
[2021-04-14 07:31:01.393][INFO] : Resource change 4607506->False
[2021-04-14 07:31:01.382][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '1408786', 'Value': 'False'}
[2021-04-14 07:31:01.383][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4784402', 'Value': 'False'}
[2021-04-14 07:31:01.390][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.394][INFO] : Resource change 4572690->False
[2021-04-14 07:31:01.418][INFO] : Resource change 4896786->False
[2021-04-14 07:31:01.412][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.414][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4607506', 'Value': 'False'}
[2021-04-14 07:31:01.415][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4537874', 'Value': 'False'}
[2021-04-14 07:31:01.381][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.419][INFO] : Resource change 4904722->False
[2021-04-14 07:31:01.448][INFO] : Resource change 835858->False
[2021-04-14 07:31:01.432][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.439][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.442][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.440][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4572690', 'Value': 'False'}
[2021-04-14 07:31:01.444][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.446][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.448][INFO] : Resource change 4283921->False
[2021-04-14 07:31:01.420][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.449][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4904722', 'Value': 'False'}
[2021-04-14 07:31:01.450][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4896786', 'Value': 'False'}
[2021-04-14 07:31:01.492][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.462][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.469][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.479][INFO] : Resource change 2080018->False
[2021-04-14 07:31:01.480][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4283921', 'Value': 'False'}
[2021-04-14 07:31:01.451][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '835858', 'Value': 'False'}
[2021-04-14 07:31:01.503][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.509][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.510][INFO] : Resource change 4088850->False
[2021-04-14 07:31:01.526][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.527][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '2080018', 'Value': 'False'}
[2021-04-14 07:31:01.529][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.535][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.539][INFO] : Resource change 3364626->False
[2021-04-14 07:31:01.550][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4088850', 'Value': 'False'}
[2021-04-14 07:31:01.549][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.556][INFO] : Resource change 4861970->False
[2021-04-14 07:31:01.565][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.568][INFO] : Resource change 1945874->False
[2021-04-14 07:31:01.569][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.581][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.583][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '3364626', 'Value': 'False'}
[2021-04-14 07:31:01.585][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.585][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4861970', 'Value': 'False'}
[2021-04-14 07:31:01.586][INFO] : Resource change 58203->True
[2021-04-14 07:31:01.599][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.616][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.624][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '58203', 'Value': 'True'}
[2021-04-14 07:31:01.617][INFO] : Resource change 2417938->False
[2021-04-14 07:31:01.633][INFO] : Resource change 4965138->False
[2021-04-14 07:31:01.616][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '1945874', 'Value': 'False'}
[2021-04-14 07:31:01.618][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.634][INFO] : Resource change 4997138->False
[2021-04-14 07:31:01.631][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.645][INFO] : Resource change 1105938->False
[2021-04-14 07:31:01.654][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '2417938', 'Value': 'False'}
[2021-04-14 07:31:01.657][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:01.673][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.674][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4965138', 'Value': 'False'}
[2021-04-14 07:31:01.691][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.676][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.679][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4997138', 'Value': 'False'}
[2021-04-14 07:31:01.683][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.674][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '1105938', 'Value': 'False'}
[2021-04-14 07:31:01.718][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.720][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.720][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.733][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.737][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.770][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.781][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.800][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 1929
[2021-04-14 07:31:01.807][INFO] : Resource change 969490->False
[2021-04-14 07:31:01.809][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.812][INFO] : Resource change 4643858->False
[2021-04-14 07:31:01.817][INFO] : Resource change 2013202->False
[2021-04-14 07:31:01.818][INFO] : Resource change 4125970->False
[2021-04-14 07:31:01.819][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.828][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.829][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '969490', 'Value': 'False'}
[2021-04-14 07:31:01.846][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.834][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:01.835][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4643858', 'Value': 'False'}
[2021-04-14 07:31:01.835][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '2013202', 'Value': 'False'}
[2021-04-14 07:31:01.829][DEBUG] : Send to jeedom :  {'method': 'updateValue', 'ResourceID': '4125970', 'Value': 'False'}
[2021-04-14 07:31:01.881][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.883][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.891][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.859][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.884][DEBUG] : Starting new HTTP connection (1): 127.0.0.1:80
[2021-04-14 07:31:01.938][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.949][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.967][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.982][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.986][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:01.996][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:02.024][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:02.043][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:02.063][DEBUG] : http://127.0.0.1:80 "POST /plugins/ihc/core/php/deamonIHC.php?apikey=<ma-clé-api> HTTP/1.1" 200 0
[2021-04-14 07:31:11.961][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:31:11.969][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:22.045][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:31:22.053][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:32.133][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:31:32.141][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:42.231][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:31:42.239][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:31:52.318][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:31:52.326][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:02.782][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:02.793][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:12.916][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:12.925][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:23.003][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:23.011][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:33.111][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:33.118][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:43.195][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:43.203][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:32:53.283][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:32:53.291][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:03.397][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:03.405][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:13.495][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:13.503][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:23.605][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:23.613][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:33.710][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:33.718][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:43.801][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:43.809][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:33:53.890][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:33:53.898][DEBUG] : Resetting dropped connection: 192.168.1.8
[2021-04-14 07:34:03.975][DEBUG] : http://192.168.1.8:80 "POST /ws/ResourceInteractionService HTTP/1.1" 200 446
[2021-04-14 07:34:03.984][DEBUG] : Resetting dropped connection: 192.168.1.8

Bonjour, j’ai mis à jour la version python3.7 vers python3.9 et j’ai toujours le même problème donc ça ne vient pas de la version python.

Voilà comment le programme est fait :

Dans mon démon plugins\ihc\resources\ihc\ihc.py :
Je lance la fonction add_notify_event() quand mon démon reçoit message['method']=='IHC_Notify'

elif message['method'] == 'IHC_Notify':
                    try:
                        for i in range(0, len(message['resids'])):
                            ResourceId = int(message['resids'][i]['ResourceID'])
                            ihc.add_notify_event(ResourceId, on_ihc_change, True)
                    except Exception as e:
                        logging.error('IHC_Notify error : '+str(e))

Dans la library la fonction add_notify_event() est la suivante :

def add_notify_event(self, resourceid: int, callback, delayed=False):
        """Add a notify callback for a specified resource id
        If delayed is set to true the enable request will be send from the
        notification thread
        """
        with IHCController._mutex:
            if resourceid in self._ihcevents:
                self._ihcevents[resourceid].append(callback)
            else:
                self._ihcevents[resourceid] = [callback]
                if delayed:
                    self._newnotifyids.append(resourceid)
                else:
                    if not self.client.enable_runtime_notification(resourceid):
                        return False
            if not self._notifyrunning:
                self._notifyrunning = True
                self._notifythread.start()

            return True

    def _notify_fn(self):
        """The notify thread function."""
        while self._notifyrunning:
            try:
                with IHCController._mutex:
                    # Are there are any new ids to be added?
                    if self._newnotifyids:
                        self.client.enable_runtime_notifications(self._newnotifyids)
                        self._newnotifyids = []

                changes = self.client.wait_for_resource_value_changes()
                if changes is False:
                    self.re_authenticate(True)
                    continue
                for ihcid in changes:
                    value = changes[ihcid]
                    if ihcid in self._ihcevents:
                        for callback in self._ihcevents[ihcid]:
                            callback(ihcid, value)
            except Exception as exp:
                self.re_authenticate(True)

    def re_authenticate(self, notify: bool = False) -> bool:
        """Authenticate again after failure.
        Keep trying with 10 sec interval. If called from the notify thread
        we will not have a timeout, but will end if the notify thread has
        been cancled.
        Will return True if authentication was successful.
        """
        timeout = datetime.now() + timedelta(seconds=self.reauthenticatetimeout)
        while True:
            if self.authenticate():
                return True

            if notify:
                if not self._notifyrunning:
                    return False
            else:
                if timeout and datetime.now() > timeout:
                    return False
            # wait before we try to authenticate again
            time.sleep(self.retryinterval)

Dans le thread ci-dessus, la fonction self.client.wait_for_resource_value_changes() est lancée :

def wait_for_resource_value_changes(self, wait: int = 10):
        """
        Long polling for changes and return a dictionary with resource:value
        for changes
        """
        changes = {}
        payload = """<waitForResourceValueChanges1
                     xmlns=\"utcs\">{timeout}</waitForResourceValueChanges1>
                  """.format(
            timeout=wait
        )
        xdoc = self.connection.soap_action(
            "/ws/ResourceInteractionService", "getResourceValue", payload
        )
        if xdoc is False:
            return False
        result = xdoc.findall(
            "./SOAP-ENV:Body/ns1:waitForResourceValueChanges2/ns1:arrayItem",
            IHCSoapClient.ihcns,
        )
        for item in result:
            ihcid = item.find("ns1:resourceID", IHCSoapClient.ihcns)
            if ihcid is None:
                continue

            resource_value = item.find("./ns1:value", IHCSoapClient.ihcns)
            value = IHCSoapClient.__get_value(resource_value)
            if value is not None:
                changes[int(ihcid.text)] = value
        return changes

Tant que mon contrôleur IHC répond bien j’ai bien une requête qui s’exécute toutes les 10secondes (timeout). Lorsque mon contrôleur ne répond pas plus rien ne se passe on dirait que le code est bloqué et que le timeout n’arrive jamais.

Le même code lancé directement en python3 depuis mon pc fonctionne correctement, pourquoi j’ai ce blocage sous Jeedom ?? Si quelqu’un peut m’aider SVP, mon plugin ne peux être opérationnel avec ce problème… :cry:

D’avance merci

Bonjour,
Je suis toujours bloqué, j’ai ouvert un ticket auprès du support pro mais pas de nouvelles…
Personne ne voit d’où ça peut venir ??

D’avance merci

Bonjour,
ça dépasse mes compétences, mais à mon avis c’est une erreur de compter sur le timeout pour ton plugin: les 10 secondes c’est paramétré où et comment? et les 2 minutes 45 c’est toi qui le gère je suppose, côté PHP ou python aussi ? C’est des requetes HTTP sur un port spécifique, ou socket ?

Bonjour, merci pour ton retour,

C’est des requêtes SOAP, mais cette partie du code est dans une library qui n’est pas de moi… les 10 secondes sont bien définies dans une constante de la library mais les 2 minutes impossible de trouver…

J’ai finalement trouvé la fonction qui envoi la requête SOAP ainsi que les paramètres de celle-ci et en faite elle n’avait pas de timeout donc je pouvais attendre longtemps… j’ai ajouté un timeout de 30secondes et du coup maintenant mon problème est réglé… rien à voir avec Jeedom finalement. En revanche je ne comprend pas pourquoi sous Windows la requête se terminait toute seule au bout de 2 minutes, peut-être une fonctionnalité interne ?? Enfin bref mon problème est maintenant résolu et je vais pouvoir publier mon plugin :slight_smile:

Merci @pifou de m’avoir fait chercher plus en détail l’histoire des 2minutes :wink:

Le timeout est toujours une fonctionnalité interne de l’OS, car l’OS fini toujours par interrompre une requête qui prend trop de temps, simplement la durée dépend d’un OS à l’autre.
C’est bien que tu aie ajouté un timeout de 30sec sur ton script, mais même la tu n’es pas à l’abris d’un OS qui serait réglé plus court et qui couperait ta requête avant ça, donc il faut rester prudent dans le traitement de ton erreur :slight_smile:

Ok bon à savoir merci pour l’info. Mais pourquoi sur ma Jeedom je n’ai pas de timeout alors ? :thinking:

En vrai, tu en a sûrement un, mais il est un peu - beaucoup - plus long, tu a laissé combien de temps ? Ou alors, Debian / PHP / Jeedom spécifie un « timeout éternel » = aucun timeout mais ça m’étonnerait, ça reste dangereux de laisser vivre des connexions sans limite de temps.

Ma jeedom a tournée des semaines sans que ça reparte donc je n’ai pas l’impression qu’il y ai de timeout…

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.