EPC Cloud: Simplifying the Internet of Things Thanks to Web Patterns: HTML 5 Websockets (Part 2/3)

Part 1: Cloud & REST | Part 2: HTML5 WebSockets | Part 3: Physical Mashups

In a recent post, we were explaining how in a project common to MIT and ETH Zurich, we simplified deployments of IoT applications based on the EPC Global standards.

We operated this simplification by applying four of the Web of Things patterns: Cloud Computing, RESTful Interface, Real-Time Web and Physical Mashups.

In the first related post we described how we used Cloud Computing and RESTful Interfaces. It is now time to talk a little bit more about one of the other pattern: the Real-Time Web.

Real-Time Web: HTML 5 WebSockets to Enable Near Real-Time Applications

Early on, experts of the RFID domain asked us to enable mobile or Web clients access to the raw data directly pushed by RFID readers. The challenge here is that the Web was designed mainly as a client-pull architecture, where clients can explicitly request (pull) data and receive it as a response (we have a paper about the matter, here!). This makes uses-cases where near real-time communication is required rather challenging. As an example, a typical use-case is one in which we would like to push events that are being recorded by an RFID reader directly to a mobile browser application for monitoring purpose.

Here, the “Real-time Web”, one of the most recent blueprints of the Web, can be leveraged. The Real Time Web encompasses several new techniques that can be used to push events directly to browsers. We focus on two of these here. The first one, called Comet (also called HTTP streaming or long-polling) is based on the concept of long-lasting HTTP connections and keep-alive messages. While this is supported by most browsers and HTTP libraries, it works by using an existing loop-hole. More recently, Websockets (part of the HTML5 drafts) were proposed. Websockets propose duplex communication with a single TCP/IP connection directly accessible from any compliant browser through a simple Javascript API. The increasing support for HTML5 in Web and Mobile Web browsers makes it a very good candidate for pushing data on the Web.

tpusher-logoFor the EPC Network, we created tPusher, a service that combines a RESTful API with a Web-socket and Comet server. Using
a RESTful API, clients can subscribe to RFID event notifications for a particular reader by using a URL such as:


This initiates a Websocket connection with the server on which RFID events recorded by READER_ID will be pushed.

Our implementation is based on the great Atmosphere framework. Atomosphere is a Java abstraction framework for enabling push support on most Java Web servers. One of the advantages of this approach is to be able to deploy tPusher on recent Web Servers such as Grizzly, which are highly optimized to push events on the Web because of their usage of non-blocking threads for each client. In order to support browsers or other clients that do not support HTML5 Websockets yet, we use a client-side abstraction Javascript library called Atmosphere JQuery Plugin which falls back to a Comet connection in case Websockets are not supported by the client.

To better understand the impact of tPusher in the context of RFID apps let us talk about our demonstration: When setting up RFID readers or maintaining existing deployments it is valuable to have a direct feedback of the tags observed by a particular reader in order to monitor the manufacturing process or to debug the readers. In the current implementations of the EPC software stack this would require to use and configure a (expert) monitoring tool such as the Fosstrak LLRP Commander on a desktop computer. Thanks to the RESTful interface to the Real-Time Web capability of tPusher, the tags observed by any reader can now be directly pushed to any browser or HTTP library.

We developed as Mobile Web page that can display them in a user-friendly manner. The page uses HTML5, Javascript with the Atmosphere JQuery Plugin. All code required for such a page to subscribe to events pushed by readers through tPusher and display them fits within 5 lines of Javascript. The code is shown below:

// called whenever an event is pushed :
function callback(response )
{alert(response.responseBody + response.transport) ;}
// subscription to the events of reader "exit1 "
$.atmosphere.subscribe (
"http://EPC_CLOUD_APPLIANCE/t-pusher/reader/exit1" ,
callback , $.atmosphere.request =
{transport : ’ websocket ’ }) ;

Add some bits of Sencha Touch HTML and CSS and you get a nice, user friendly mobile Web application within a few hours of work. The app does not require any installation (just access a URL!) and works accross mobile Web browsers (e.g., iPhone Webkit, Android Webkit / Firefox mobile, etc.)

In a next post we will talk about the last pattern: Physical Mashups.

For those who can’t wait, you can already sneak into the presentation of the full project below.

Dominique Guinard