How to Tell If Your WebSocket Connection Is Native or Emulated

How can you tell if your WebSocket connection is native or emulated? This question came up during our recent webcast.

First, this isn’t something you need to loose sleep over, your WebSocket server should take care of this automatically for you, that is falling back to the most efficient emulation if native support is not available (for whatever reason, such as browser limitations or proxies or other network intermediaries breaking the native WebSocket connection). The Kaazing WebSocket Gateway does this exceptionally well in a 100% transparent manner, providing virtually the same performance with emulation as native WebSockets.

Possibly the easiest way to confirm whether your connection is native or emulated, is by using the Chrome or Safari Developer tools. Point your browser to http://websocket.org, and bring up the Developer Tools (Safari: Develop > Start Debugging JavaScript, Chrome: View > Developer > Developer Tools). Select Network, and optionally the WebSocket filter down below. Upon establishing the WebSocket connection, a new entry shows up in the Path column. Click the path to see its contents information about it.

If the WebSocket connection is native, you’ll see an HTTP request with the Upgrade header: WebSocket and an HTTP response with Upgrade header: WebSocket.

In case of emulation, you won’t see the upgrade header in the response: