Dweet.io Library

I like the simplicity of this publish/subscribe service and Freeboard. Looks like Verizon feels the same way (see ThingSpace). The library works fine with one exception: the Stream function fails with status code 18.

The function has “reconnect” logic for status 28 but looks like the code was copied from the Twitter library without adjusting it for Dweet.io, see “stream(searchTerms, onTweet, onError);”.

Also, the instructions for getLatest should be changed from client.get to client.getLatest.

Error 18 is that the server told us it’d send us X bytes, but sent us less than X.

Does it fail before any data is received?

No, it fails after receiving multiple dweets. I changed the “reconnect” code (the parameters for the stream function and a check for code 18). Now I received a 52.
if (resp.statuscode == 18 || resp.statuscode == 28 || resp.statuscode == 200) { server.log("Reconnecting...") stream(thing, callback);

Looks like adding a check for 52 (nothing was returned from the server) took care of the problem. Interesting that the reconnects are not random. Usually every 60 seconds, or exactly 2 min, 6 min, etc. Must be something on the Dweet.io side.

2016-02-26 11:51:34 UTC-5 [Agent] Reconnecting…
2016-02-26 11:51:34 UTC-5 [Agent] Opening stream for: o123456
2016-02-26 11:52:34 UTC-5 [Agent] Reconnecting…
2016-02-26 11:52:34 UTC-5 [Agent] Opening stream for: o123456
2016-02-26 11:58:33 UTC-5 [Agent] Reconnecting…
2016-02-26 11:58:33 UTC-5 [Agent] Opening stream for: o123456
2016-02-26 11:59:33 UTC-5 [Agent] Reconnecting…
2016-02-26 11:59:33 UTC-5 [Agent] Opening stream for: o123456
2016-02-26 12:00:33 UTC-5 [Agent] Reconnecting…
2016-02-26 12:00:33 UTC-5 [Agent] Opening stream for: o123456