WebThingsIO / thing-url-adapter

Proxy adapter for Web Thing API endpoints
Mozilla Public License 2.0
22 stars 18 forks source link

Not reconnecting to remote thing after network interruption #17

Closed Timmeey closed 6 years ago

Timmeey commented 6 years ago

After adding a remote Thing, when the thing goes down (network outage and whatnot), it doesn't reconnect to this thing after it is available again.

Reproduce:

  1. Start remote web thing
  2. add remote web thing as a thing
  3. check that the thing is showing properly and is getting updates (fake sensor updating itself every few seconds)
  4. disconnect/restart the remote web thing
  5. the updating of the things sensor value in the UI stops
  6. Wait a bit, reload the ui
  7. Still not updating the things sensor value

Expected:

  1. Start remote web thing
  2. add remote web thing as a thing
  3. check that the thing is showing properly and is getting updates (fake sensor updating itself every few seconds)
  4. disconnect then reconnect XOR restart the remote web thing
  5. the updating of the things sensor value in the UI stops
  6. Wait a bit (maybe even reload the UI)
  7. The things sensor reading is updating again
hobinjk commented 6 years ago

I was unable to reproduce on the master branch of the gateway using thing-url-adapter with my esp8266-wot sketch modified to act like a sensor.

What versions of everything are you running? I'm also curious about how long you leave the remote web thing disconnected (whether it's greater than 30 seconds)

Timmeey commented 6 years ago

I'm using 7c1efa0f392be1f53047b3d3261dd6d5cb150d8f together with the java-webthing project.

Once i stop the java-webthing server and then restart it, it seems that the gateway just doesn't reconnect anymore with the websocket. after i restart the gateway all is well again.

Hmm... Until now i only restarted it, so it was down for less than 10 seconds. Will try to get more detailed data including timings and logs.

but right now, something is acting up, and i can't establish a connection at all and the gateway is crashing (different issue)

hobinjk commented 6 years ago

Oh, interesting. It's likely an issue with the websocket interface specifically then since the esp8266 doesn't do that. This should be enough information to get a fix done

Timmeey commented 6 years ago

Thank you :-)

Maybe a little bit off-topic, but how does the esp8266 push sensor updates to the gateway then?

hobinjk commented 6 years ago

You're welcome!

The thing-url-adapter polls the esp8266 every 5 seconds for changes

mrstegeman commented 6 years ago

It's possible that this isn't doing the right thing: https://github.com/mozilla-iot/thing-url-adapter/blob/master/thing-url-adapter.js#L226