aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
964 stars 384 forks source link

Device does not detect offline state/network connection loss #194

Closed James-Firth closed 6 years ago

James-Firth commented 6 years ago

I've created an instance of awsIot.device and wrapped it with some listeners. I'm doing this in-browser running the webserver locally.

I've noticed I'll get errors if I disable the network for my machine (at the os level) before the client tries to connect.

However, if I disable my networking after the connection has occurred even after waiting for over a minute.

I tried switching around the config I passed it in a futile attempt to get the any of the expected events to emit.

Here is part of my config:

        protocol: 'wss',
        keepAlive: 10,
        connectTimeout: 2000,
        maximumReconnectTimeMs: 10000,
        minimumReconnectTimeMs: 4000,

Which if I understand correctly should show an error relatively quickly.

Thanks for any help

EDIT: It seems to finally error after about 10 minute and I can't find where that limit would occur.

I've also discovered in browser my code seems to be toggling between offline and online quite frequently despite there being a network connection now.

However, it seems in a node terminal it stays alive, but in browser it has issues.

Any thoughts on configuration issues that could be causing this? I feel like I'm missing something, but I've read documentation and dove into the code to try and suss this out. I also turned on debug mode but get no errors.

James-Firth commented 6 years ago

I discovered the issue, it was multiple tabs open and a static (therefore repeated) clientID

jeremistadler commented 6 years ago

@James-Firth Having the same issue, did you find where the disconnect timeout is?