Chapter 5. WebSocket Compatibility
The technology behind WebSocket is to allow bidirectional communication between client and server. A native WebSocket implementation minimizes server resource usage and provides a consistent method of communicating between client and server. As with the adoption of HTML5 in client browsers, the landscape of support is relegated to modern browsers. That means no support for any user with Internet Explorer less than 10, and mobile browser support less than iOS Safari 6 and Chrome for Android.
Here are just some of the versions with RFC 6455 WebSocket support:
-
Internet Explorer 10
-
Firefox 6
-
Chrome 14
-
Safari 6.0
-
Opera 12.1
-
iOS Safari 6.0
-
Chrome for Android 27.0
This chapter outlines options for supporting older browsers that predate the WebSocket RFC 6455 spec when you want to take advantage of bidirectional communication in your application. The platforms you’ll look at solve compatibility issues with older client browsers, and add a layer of organization for your messages.
SockJS
SockJS is a JavaScript library that provides a WebSocket-like object in the browser. The library is compatible with many more browsers due to its conditional use of multiple browser transports. It will use WebSocket if the option is available as a first choice. If a native connection is not available, it can fall back to streaming, and finally polling if that is also unavailable. This provides nearly full browser and restrictive proxy support, as shown ...
Get WebSocket now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.