Server WebSocket: Old Fashion in New Style

Websockets have historically been important in programing gaming or currency and commodity market feed apps where a back and forth real time communication is needed. This is especially true in the opposite direction, meaning updates pushed to the client browser or app by the back end, which is something like an architecture retrofit to fill a gap. Because of this ability and changing circumstances programmers and architects are finding new applications for websockets either for web pages that update themselves or the much larger market of IoT (Internet of Things) applications.

Websockets is a protocol that allows programs to communicate with each other in a continuous, bi-directional manner. It does this by making a TCP connection and then keeping it open.  

It’s different than a web browser, web server TCP connection in that the server side can send an update to the client without the client having to ask the server to hang on to that.  In the absence of Websockets websites use Ajax long polling to emulate that behavior.Websockets is particularly useful when data is needed right now and when the amount of data is large.Most browsers support Websockets. To request that type of connection, the browser sends an update request in the HTTP header to ask it to switch to Websockets (ws) or Secure WebSockets (wss).

XMPP WebSockets

Jabber is a chat program that was popular long before ordinary people were familiar with chat. Jabber uses the XMPP protocol, as does WhatsApp.  XMPP rides atop TCP, which is the protocol layer that handles the application layer HTTP traffic. XMPP can be used in IoT applications riding atop HTTP or Websockets.  (It is more widely used with Websockets than HTTP because there is less communication overhead.) IoT will push XMPP and websockets towards explosive growth.  

This is because applications like industrial monitoring and control, smart homes and automobiles, etc. are being rolled out by the largest of companies, and niche players as well, with great urgency.  IoT lets companies tap into the ability to do analytics on retrieve sensor data from devices in the field either over the internet or short-range radio, like NFC or Bluetooth 4, to improve industrial, retail, advertising, and other operations.  IoT has created and will create thousands of new businesses and new sources of revenue for existing businesses.

MQTT WebSockets

MQTT is another IoT transport layer mechanism.  It transports using a MQ (message queue) publish-and-subscribe model, a concept that has been in use for many years in business, although MQTT is much newer and somewhat different than regular MQ.Amazon AWS recently announced support for MQTT WebSockets on their IoT cloud. They completely disagree with some writers who have been putting wrong information on the internet saying that Ajax scales better than Websockets implying that there is some limitation to Websockets.  Amazon writes that MQTT over Websockets, “... easily scales to millions of simultaneous users.”  What cannot scale infinitely in any architecture is HTTP, which Ajax requires.

Websocket Adopters: Trello and Stack Overflow

Trello and StackOverflow use WebSockets to allow instant updating of the page when a user makes a changes.  So, someone using Trello project management, workflow software would see an update to the card (task) right away when another user makes a change.  The same is true with Stack Overflow.

Websockets can be a replacement for Ajax (built into jQuery) for asynchronous communications, meaning have the application go off and do something else while waiting for a communication response.  Ajax rides atop HTTP.  

That means it opens a TCP connection to a web server that serves up a request and closes off the connection unless there is a KEEP ALIVE header.  So it’s the same as Long Polling. Websockets do not need anHTTP layer nor any kind of KEEP ALIVE signal.

Sockets.io

Sockets.io is a Websockets framework designed to make Websocket programming easier.  Programmers can use it to write the server side application, such as a Node.js HTTP server, and the client.  It adds listeners to respond to communication requests. It can fall back to older communications vehicles, like Adobe Flash, when the client application does not support Websockets. (That’s not always very useful as Flash is banned from some platforms, like the iPhone, due to its security problems and Apple’s desire not to be dependent on a 3rd party company.) So the Sockets.io framework takes away the need to program all that communication complexity from the programmer.

Putting it to Use

One obvious use of Websockets would be that stock ticker, currency conversion rates example we mentioned above.  But there are many more that would have a much larger impact on business.  That includes streaming big data from Apache Storm to a web browser to make it come alive with sales, fleet operations, industrial processes, and other IoT and analytics applications.  All of that pushes Websockets forward taking it out of the realm of games and geeks and putting it to work for corporations.

Conclusion

Everything you need to know about outsourcing technology development Access a special Introduction Package with everything you want to know about outsourcing your technology development. How should you evaluate a partner? What components of your solution that are suitable to be handed off to a partner? These answers and more below.

Let's Talk
Lets Talk

Our Latest Blogs

With Zymr you can