Presences Format

A presence is emitted by CloudConnect and sent via the notification service every time a device connects, reconnects or is disconnected.

id
~ Required integer - 64 bits unique track identifier.

id_str
~ Required string - String version of the identifier (for languages not supporting 64 bits integers).

connection_id
~ Required integer - 64 bits unique connection identifier (see Notification for more details).

connection_id_str
~ Required string - String version of the connection identifier (for languages not supporting 64 bits integers).

type
~ Required string - connect | disconnect|failed_connect.
~ disconnect : presence sent when the server closes the communication socket with the device (see a list)
~ connect : presence sent when the device connects or reconnects to server (see a list)
~ failed_connect : presence sent when the device can't connect to the server. In this case, asset is unknown and will be set to null.
~ declare_asset : presence sent when the asset is declared for the first time on the platform

reason
~ Required string - Reason given by the server or the device for the [re|dis]connection.

asset
~ Required string - IMEI of the device. Note: can be null (see failed_connect).

time
~ Required string - When the event was created by the CloudConnect (timestamp in RFC 3339 format: YYYY-MM-DDTHH:MM:SS+AA:BB).


Connection and reconnection reasons

When a device connects to the server, it gives the reason for its connection (usually why it was disconnected from the server from its point of view).

Note that it is from the device's point of view.

  • cold_boot : the device was turned off, which closed the connection on the device's side
  • suspend_boot : the device was turned off, which closed the connection on the device's side (for device's with a screen)
  • idle_out : the device went into idle, which closed the connection on the device's side
  • ppp_lost : device lost the ppp, which closed the connection on the device's side
  • modem_reset : the device's modem was reset, which closed the connection on the device's side
  • sim_error : the device's sim card was removed, which closed the connection on the device's side
  • write_error : the device was unable to write to the socket, and closed the connection on the device's side
  • read_error : the device was unable to read from the socket, and closed the connection on the device's side
  • closed_by_server : the device tried to write to the socket, but the socket had been closed (by the server, the ISP...)

warning This list is not exhaustive, so make sure your application can handle other reasons.


Disconnection reasons

When a the server closes the communication socket with the device, it gives its reason for closing the socket.

  • socket_closed : the server tried to write to the socket, but the socket had been closed (by the device, the ISP...)
  • network_error : the server received a tcp error when communicating on the socket, and closed the connection
  • client_disconnect : the device sent a disconnect symbol
  • network_activity_timeout : we exceeded the network_activity_timeout with no activity on the socket
  • message_ack_timeout : the server timeouted while waiting for the device to acknowledge a message
  • basevalue_ack_timeout : the server timeouted while waiting for the device to acknowledge a basevalue (used to send relative timestamps and message ids)
  • unknown_channel : a message was sent on a channel that was not set in the cloud
  • unknown_dynamic_channel : the device tried to communicate on a channel using a stale id, so the server closed the connection
  • server_shutdown : the server was restarted, closing all active connections with the devices
  • Unhandled reason 95074823, please contact maintainer : another error occurred

warning This list is not exhaustive, so make sure your application can handle other reasons.

{
  "id":461799503595297635,
  "id_str":"461799503595297635",
  "connection_id":461799503595298293,
  "connection_id_str":"461799503595298293",
  "type":"disconnect",
  "reason":"socket_closed",
  "asset":"357322041802978",
  "time":"2013-06-28T09:46:21+02:00"
}

This example presence has the following properties:

  • the disconnected asset is 357322041802978.
  • the socket was closed by the device, the network provider, or network conditions