Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not reconnecting to Sinric Server after Internet Drop #92

Closed
akaith opened this issue Oct 6, 2020 · 11 comments
Closed

Not reconnecting to Sinric Server after Internet Drop #92

akaith opened this issue Oct 6, 2020 · 11 comments

Comments

@akaith
Copy link

akaith commented Oct 6, 2020

This is a general problem i faced with the old version of sinric as well as the new one, whenever there is a wifi drop from ISP, the nodemcu doesnt seem to detect it, also whenever the internet is back again it doesnt seem to reconnect to the sinric server. The only solution i found was to reset the nodemcu after every internet drop, but that seems to defeat the purpose of home automation. Any solution for the same??? Thanks

@akaith akaith changed the title Not reconnecting to Sinric Server after Interent Drop Not reconnecting to Sinric Server after Internet Drop Oct 6, 2020
@sivar2311
Copy link
Collaborator

Usually this is handled by SinricPro SDK and i have tested this (see below).
If the websocket connection is disconnected, the SDK reconnects automaticly. Implemented here and here.
Additionally a user defined callback is called, which can be set by using SinricPro.onDisconnected see here for more information / example code.

The SDK and the SinricPro server makes use of the websocket ping/pong protocol.
On SDK side a ping is sent every 5 minutes and timesout after 10 seconds. Retry count is set to 2, so at least after 10 minutes the underlying websocket should securely detect the disconnection.

Reconnect test:

[SinricPro:Websocket]: connected
Connected to SinricPro
[SinricPro:Websocket]: receiving data
[SinricPro.handleReceiveQueue()]: 1 message(s) in receiveQueue
[SinricPro.handleReceiveQueue()]: Signature is valid. Processing message...
[SinricPro:extractTimestamp(): Got Timestamp 1602007627
[SinricPro:Websocket]: disconnected
Disconnected from SinricPro
[SinricPro:Websocket]: connected
Connected to SinricPro
[SinricPro:Websocket]: receiving data
[SinricPro.handleReceiveQueue()]: 1 message(s) in receiveQueue
[SinricPro.handleReceiveQueue()]: Signature is valid. Processing message...
[SinricPro:extractTimestamp(): Got Timestamp 1602007937

As you can see there is a gap by exact 310 seconds between both timestamps (5 Minutes and 10 seconds).

@akaith akaith closed this as completed Oct 7, 2020
@sivar2311
Copy link
Collaborator

Any info on this? (You closed this issue without a comment)

@akaith akaith reopened this Oct 7, 2020
@akaith
Copy link
Author

akaith commented Oct 7, 2020

I was testing various possibilities with the internet drop. I found that whenever the drop is longer that 5 mins, it detected the drop successfully and whenever internet was back on, it immediately reconnected. But i found a problem when the internet drop was less than 5 minutes, the device is unable to respond even after the internet was functioning properly. Any solution for this????

@sivar2311
Copy link
Collaborator

The test i did (above) was such a short drop (took less than a minute) and was detected sucessfully after 5min 10seconds.
How long did you wait?

@akaith
Copy link
Author

akaith commented Oct 7, 2020

The wifi network is available all the time, the drop occurs when the wifi router isnt connected to the internet due to a problem at the ISP end. If the ssid itself isnt available then i got the same results as u. What i was mentioning was that the wifi ssid is available and connected, but isnt connected to the internet. In such a case, after about 5 minutes when a ping is sent, and the internet(not ssid) is down, the server disconnection is detected and whenever the internet is back, the device reconnects. As i mentioned before, when this internet(not ssid) outage is less than 5 minutes then it does not detect either outage nor reconnection occurs. To try this, I suggest u remove the WAN input of ur router or switch of mobile data if using a hotspot after the device has connected successfully to the ssid.
Hope the problem description is detailed enough for u to understand . Thanks

@sivar2311
Copy link
Collaborator

I have understood the error exactly. And did exactly what you suggested (disconnect the Internet connection). The WiFi was available all the time and the ESP was connected to it. Only the Internet connection was disconnected for less than a minute. You can see the result in my log above. Everything worked perfectly.

Which version of the Arduino framework do you use?

The problem could be both the underlying TCP layer and your router. Both are things that the SDK cannot influence.

There are similar discussions in the websocket repository.
Links2004/arduinoWebSockets#363
Links2004/arduinoWebSockets#203

The SDK is based on this websocket library.

@akaith
Copy link
Author

akaith commented Oct 7, 2020

Im using Arduino version 1.8.13 , esp8266 - version 2.7.4, Im using a TP-Link router. I tried the same using mobile hotpot as well but had the same result. Anything u can suggest that i do, to be able to use the device to its full potential

@sivar2311
Copy link
Collaborator

I am using VS-Code PlatformIO but same Arduino Framework Version (2.7.4) and my router is a AVM FritzBox 7490.
I don't have any other suggestions, but a question: How did you the test with mobile hotspot? This will disconnect the WiFi, not only the ISP connection?!

@akaith
Copy link
Author

akaith commented Oct 7, 2020

I use mobile data on mobile hotspot, n connect my alexa and nodemcu to same network

Is there a way to change to 5 minute ping to something shorter??

@sivar2311
Copy link
Collaborator

No, there are no plans to shorten the ping time.
Solution for you could be to try http request to google.com or somete other website and check if the connection can be established.

@akaith
Copy link
Author

akaith commented Oct 7, 2020

Thanks

@akaith akaith closed this as completed Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants