Closed emnik closed 4 years ago
Websockets: https://github.com/Links2004/arduinoWebSockets/releases/tag/2.1.1 JSON: https://github.com/bblanchon/ArduinoJson/releases/tag/v5.13.2
not sure about others as I have not used them in Sinric
I found the issue. I had static IPs but I had not defined a DNS server! So while I had DHCP everything worked fine. After the static IPs new configuration, although the esps were connecting to the network they could not resolve the iot.sinric.com IP reporting a DNS lookup error -5 in the debug mode of websockets. Setting a dns server for the static ip configuration solved the problem and everything is up again!
Thanks for the explanation. Good to know
why do you need to specify a DNS server? I don’t get it. Do you have some kind of special network going on there?
On Sat, 28 Sep 2019 at 5:08 AM Nikiforakis Manos notifications@github.com wrote:
I found the issue. I had static IPs but I had not defined a DNS server! So while I had DHCP everything worked fine. After the static IPs new configuration, although the esps were connecting to the network they could not resolve the iot.sinric.com IP reporting a DNS lookup error -5 in the debug mode of websockets. Setting a dns server for the static ip configuration solved the problem and everything is up again!
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/kakopappa/sinric/issues/344?email_source=notifications&email_token=ABZAZZUETDONNVUAS4QW2ETQLZ74TA5CNFSM4I3FCKIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72GUNA#issuecomment-536111668, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZAZZW6AQWVPVAW4Y3PR3DQLZ74TANCNFSM4I3FCKIA .
This is a good question. No I don't have any special network. Furthermore I works fine when on DHCP. Now when I switched to Static IPs, with:
// Static IP address configuration
IPAddress staticIP(192, 168, 1, 63); //ESP static ip
IPAddress gateway(192, 168, 1, 1); //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0); //Subnet mask
and:
WiFi.mode(WIFI_STA);
WiFi.config(staticIP, gateway, subnet);
WiFi.begin(MySSID, MyWiFiPassword);
I got (every 5 seconds:)
[WSc] Webservice disconnected from sinric.com!
Then I enabled the debug option in WebSockets.h (#define DEBUG_ESP_PORT Serial) and in Arduino IDE (Tools>Debug Port > Serial & Tools> Debug Level > WiFi) and run the sketch again. This time I got:
[WS-Client] connect ws...
[hostByName] request IP for: iot.sinric.com
[hostByName] Host: iot.sinric.com lookup error: -6! // sometimes error: -5!
[WS-Client] connection to iot.sinric.com:80 Faild
[WS-Client] client disconnected.
[WSc] Webservice disconnected from sinric.com!
So I suspected a dns lookup error. Adding the DNS option:
IPAddress staticIP(192, 168, 1, 63); //ESP static ip
IPAddress gateway(192, 168, 1, 1); //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0); //Subnet mask
IPAddress dns(1, 1, 1, 1); //DNS This can also be IPAddress dns(192, 168, 1, 1)
and
WiFi.mode(WIFI_STA);
WiFi.config(staticIP, gateway, subnet, dns);
WiFi.begin(MySSID, MyWiFiPassword);
Then everything worked and the debug messages were:
IP address: 192.168.1.63
[WS-Client] connect ws...
[hostByName] request IP for: iot.sinric.com
[hostByName] Host: iot.sinric.com IP: 198.23.139.123
[WS-Client] connected to iot.sinric.com:80.
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET / HTTP/1.1
Host: iot.sinric.com:80
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: xxxxxxxxxxxxxxxxxxxxxx
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[write] n: zu t: 327
[WS-Client][sendHeader] sending header... Done (30902us).
[WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS-Client][handleHeader] RX: Server: nginx/1.10.3 (Ubuntu)
[WS-Client][handleHeader] RX: Date: Sat, 28 Sep 2019 11:04:10 GMT
[WS-Client][handleHeader] RX: Connection: upgrade
[WS-Client][handleHeader] RX: Upgrade: websocket
[WS-Client][handleHeader] RX: Sec-WebSocket-Accept: 8/xxxxxxxxxxxxxxxxxxxxxxxxxxx
[WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS-Client][handleHeader] Header read fin.
[WS-Client][handleHeader] Client settings:
[WS-Client][handleHeader] - cURL: /
[WS-Client][handleHeader] - cKey: xxxxxxxxxxxxxxxxxxxxxxxxx
[WS-Client][handleHeader] Server header:
[WS-Client][handleHeader] - cCode: 101
[WS-Client][handleHeader] - cIsUpgrade: 1
[WS-Client][handleHeader] - cIsWebsocket: 1
[WS-Client][handleHeader] - cAccept: 8/xxxxxxxxxxxxxxxxxxxxxxxxxx
[WS-Client][handleHeader] - cProtocol: arduino
[WS-Client][handleHeader] - cExtensions:
[WS-Client][handleHeader] - cVersion: 0
[WS-Client][handleHeader] - cSessionId:
[WS-Client][handleHeader] Websocket connection init done.
[WS][0][headerDone] Header Handling Done.
[WSc] Service connected to sinric.com at url: /
Waiting for commands from sinric.com ...
So I guess that when ESPs use static IPs they don't look up the DNS address through the router's configuration but we have to specify the DNS server to use (that is either the router's IP or a generic DNS IP as Cloudflare's, Google's ...)
Maybe wrong here but this seem to be the case...
Hi! can someone please give me the working versions for the libraries used for Websockets Pubsubclient and ArduinoOTA that use for