Exosite communication eventually fails on Arduino with XBee


#1

I’m using an Arduino to send data to Exosite every 5 minutes. It works for about a day or sometimes more, but eventually it stops working and I’m trying to track down the cause. I left my laptop connected to the Arduino so that I could see exactly when it fails.

The last good transmission was this:

POST /onep:v1/stack/alias HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK: my CIK here
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 213

fAirTemp0=78.8&fAirTemp1=69.1&fAirTemp2=64.9&nFanStatus0=0&nFanStatus1=0&nFanStatus2=1&fHumidity0=43.4&fHumidity1=41.0&fHumidity2=37.6&nLightLux0=31&nLightLux1=57&nLightLux2=42&nRsvrLvl0=1&nRsvrLvl1=1&nSupplyLvl=1

This is what I got back from Exosite:

HTTP/1.1 204 No Content

Server: nginx/1.2.1

Date: Sat, 06 Dec 2014 13:47:06 GMT

Content-Length: 0

Connection: keep-alive

The next transmission failed and this is what I sent:

POST /onep:v1/stack/alias HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK: my CIK here
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 214

fAirTemp0=79.0&fAirTemp1=69.3&fAirTemp2=64.0&nFanStatus0=0&nFanStatus1=0&nFanStatus2=0&fHumidity0=39.5&fHumidity1=50.1&fHumidity2=48.6&nLightLux0=31&nLightLux1=124&nLightLux2=59&nRsvrLvl0=1&nRsvrLvl1=1&nSupplyLvl=1

I got no response from Exosite. The only difference I can see is that the content length is one character longer, but otherwise it is identical. It seems once I lose communication it never recovers. Does anyone have an idea about what could be causing this problem?


#2

There are no limits on the total amount of data that the API will accept. (There are limits on the individual datapoints and the aggreate amount of data stored in the platform: https://support.exosite.com/hc/en-us/articles/200845344-Data-Limits-and-Retention)

What Arduino and network connection type are you using? I’ve actually had another user tell me about something similar in a Yun. It seems to me that something is dying in the connection between the micro and the networking hardware (which is actually a linux comupter). I haven’t figured out exactly what is going wrong, but I can only assume that it is probably my fault since there aren’t masses complaining about it on the Arduino forums…

Sorry I don’t have a better answer for you, but if you figure out anything, let me know. Also, there are some debug headers that you can uncomment to make the library print more information about what is actually going on. If you can catch the log at the time that it starts failing with the debug level 3 on, I can probably figure out what exactly is going wrong.

–Patrick


#3

I’m using an Arduino Mega and I’m connecting to my wireless network via an XBee. I checked my code and I’m sending the data to 173.255.209.28 port 80 using TCP protocol. I will try to get some more information using the debug headers, but do any of these parameters raise a red flag?


#4

It occurred to me that you’re probably assuming I’m using the Exosite library for Arduino. I’m not doing this because I’m not using an Ethernet shield or a WiFi shield. Perhaps the library can work with an XBee, but I’ve never tried doing this. Perhaps there’s something different in the way that the library sends commands to Exosite than the way I’m doing it, although I tried to follow Exosite’s instructions exactly.


#5

Ah, I was assuming that.

I’ve never used the XBee WiFi (I assume?) devices, so I don’t know of any gotchas off the top of my head. I would suggest starting with just making a simple request to something like http://time.webscript.io/?format=unix and seeing if that fails eventually too. If it does, I’d guess that it’s getting disconnected from the network, but no realizing it yet and not reconnecting automatically.

Even if you were doing something wrong, you should still get something back. The only way that I know of to not get a reply is if your HTTP request doesn’t have a “\r\n\r\n” (eg a blank line) after the headers as the server will just sit there waiting for you to finish your request. Although, even with that you should eventually get an HTTP 408 Request Timeout error from the server.

If you want to post your code, I can take a look and see if anything stands out to me.

Also, you can use the Exosite library with any network device that has a client library, but a quick search didn’t turn up one for the XBee.


#6

It may be that the XBee gets disconnected from my WiFi network and doesn’t try to automatically reconnect. I’ll have to do some more investigation to see if this is the case. However now I’m having a different issue. I haven’t changed what I send to Exosite, but for the last few days I’ve been getting a 502 error. Here’s what I receive from Exosite when I try to write data:

HTTP/1.1 502 Bad Gateway
Server: nginx/1.2.1
Date: Sun, 28 Dec 2014 01:55:17 GMT
Content-Type: text/html
Content-Length: 172
Connection: keep-alive

<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>

Has the Exosite server been having problems for the last few days?


#7

We strongly recommend not using of hard-coded IP addresses and that specific server, although it has been up for a number of years, has been offline for a few days. This server is only a proxy, it is not our main server, it’s purpose is to handle some hard-coded device communication (like yours). We attempt to keep old server IP’s online and using a proxy for as long as we can but we can’t guarantee an IP address will always remain. Please use ‘m2.exosite.com’ or other applicable Exosite API hostname for better future service.

If you have found some open-source code that uses a hard coded IP address, please let us know so we can get it updated.


#8

As far as I know, I have to give the XBee an IP address rather than an URL. In order to tell the XBee where to send data I have to specify a destination address which must be input in the form of an IP address. If you know a way around this, please let me know. If not, how do I know what IP address I should send data to? For some reason if I ping 173.255.209.28 I get a response, but pinging m2.exosite.com (54.183.196.206) gives no response.


#9

Generally our servers do not allow ping through, as it is not a part of our API nor do we need it for testing (which is the purpose of ping). If you would like a simple test, you can do a HTTP GET request to http://m2.exosite.com/timestamp or https://m2.exosite.com/timestamp which will return the current unix timestamp of the platform.

We do not recommend using hard-coded IP addresses because the servers we use can change as we add more distribution of the platform, add functionality, improve performance, load balancing, etc. Each server has a hard-coded IP address and so these hard-coded IP addresses may not always be under our control. Some of our older severs may still have a proxy up and running like 173.255.209.28 and may respond to pings, but this should not be assumed to always be available.

Is this XBEE a WiFi XBEE or a Zigbee XBEE? I would assume that the device can support DNS, have you asked the manufacturer or looked in their help guides / forums?


#10

I’m using a Wifi XBee. I looked at the manual and it looks like it can support DNS, but I still need to give it the address of the DNS server in 0.0.0.0 format. Can you provide that?


#11

There are a number of public DNS servers out there.
https://duckduckgo.com/?q=public+DNS&ia=answer

For example, one of Google’s DNS servers is: 8.8.8.8