Page 1 sur 2

Requete JSON HTTP

Publié : 07 sept. 2017, 14:47
par donk7413
Bonjour,
j’ai essayé de reproduire la fonction disco (http://domo-attitude.fr/milight-domotic ... es-discos/) (en jouant un peu plus) malheuresement j’ai une erreur domoticz a l’execution :

Code : Tout sélectionner

Error: Error opening url: http://127.0.0.1/json.htm?param=switchlight&type=command&idx=25&switchcmd=Off
Voici mon URL

Code : Tout sélectionner

https://127.0.0.1:443/json.htm?param=switchlight&type=command&idx=25&switchcmd=Off
Je précise que l’url marche (en mettant l’ip de mon RPI (192.168.1.91) depuis un navigateur et retourne OK

mais depuis domoticz ou depuis le shell avec curl, ca ne marche pas;

Shell avec curl :

Code : Tout sélectionner

pi@raspberrypi:~/domoticz $ curl -k -vvv https://127.0.0.1:443/json.htm?param=switchlight&type=command&idx=25&switchcmd=Off
[1] 11719
[2] 11720
[3] 11721
[2]-  Done                    type=command
pi@raspberrypi:~/domoticz $ * Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
*        subject: C=NL; ST=MyState; O=Domoticz; L=Domoticz; CN=*.domoticz.com; OU=Unit51; emailAddress=your@email.com
*        start date: 2015-05-23 06:49:02 GMT
*        expire date: 2025-05-20 06:49:02 GMT
*        issuer: C=NL; ST=MyState; O=Domoticz; L=Domoticz; CN=*.domoticz.com; OU=Unit51; emailAddress=your@email.com
*        SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /json.htm?param=switchlight HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Length: 91
< Content-Type: text/html
< Set-Cookie: SID=none; HttpOnly; path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT
<
* Connection #0 to host 127.0.0.1 left intact
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Mon domoticz est en HTTPS Only

Avez-vous une idée ?

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:01
par jackslayter
laissez l'adresse "192.168.1.91" au lieu "127.0.0.1" dans le script

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:03
par donk7413
J'ai malheureusement déjà essayé, ça ne change rien.

De plus j'ai certains appels qui passe avec IFTTT et google assistant, et ils fonctionnent depuis l'adresse externe.
On dirait que le raspberry pi ne veut pas exécuter de requête lui même.

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:18
par jackslayter
il faut mettre des "

Code : Tout sélectionner

curl -k -vvv "https://127.0.0.1:443/json.htm?param=switchlight&type=command&idx=25&switchcmd=Off"

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:23
par donk7413
Deja essayer aussi, j'ai mis des " pour encapsuler l'URL, j'ai aussi essayer en remplacant l'IP par 192.168.1.91 (avec et sans le port)

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:24
par jackslayter
bizarre cela marche chez moi

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:26
par donk7413
j'ai aussi essayer avec mon mot de passe et mon login : login:mdp@ip . comme sur mes requetes externes (pour IFTTT j'ai fait comme ca), rien n'y fait, cest comme si le raspberry pi refuse de se lancer lui même les url, curl www.google.fr marche bien pourtant et le raspberry pi va sur internet

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:28
par jackslayter
avec un sudo ?

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:35
par donk7413
Avec sudo et sans,
Je pense avoir essayé une bonne vingtaine de combinaison.
Cela pourrait venir de la config de mon domoticz ou mon rpi ?

Re: Requete JSON HTTP

Publié : 07 sept. 2017, 15:38
par jackslayter
faudrait essayer en HTTP simple pour voir si cela viens du SSL, après je pense pas que le pi soit en cause