Echo Test

The first section of this page will let you do an HTML5 WebSocket test against the echo server. The second section walks you through creating a WebSocket application yourself.

You can also inspect WebSocket messages using your browser.

Try it out!

This browser supports WebSocket.

Uh-oh, the browser you're using doesn't have native support for WebSocket. That means you can't run this demo.

The following link lists the browsers that support WebSocket:


Use secure WebSocket (TLS)




  1. Press the Connect button.
  2. Once connected, enter a message and press the Send button. The output will appear in the Log section. You can change the message and send again multiple times.
  3. Press the Disconnect button.
Note: In some environments the WebSocket connection may fail due to intermediary firewalls, proxies, routers, etc. In that case take advantage of WebSocket's secure capability and check Use secure WebSocket (TLS). Even if you have no issues you can still feel free to test using a secure connection.

Creating your own test

Using a text editor, copy the following code and save it as websocket.html somewhere on your hard drive. Then simply open it in a browser. The page will automatically connect, send a message, display the response, and close the connection.

  <!DOCTYPE html>
  <meta charset="utf-8" />
  <title>WebSocket Test</title>
  <script language="javascript" type="text/javascript">

  var wsUri = "ws://";
  var output;

  function init()
    output = document.getElementById("output");

  function testWebSocket()
    websocket = new WebSocket(wsUri);
    websocket.onopen = function(evt) { onOpen(evt) };
    websocket.onclose = function(evt) { onClose(evt) };
    websocket.onmessage = function(evt) { onMessage(evt) };
    websocket.onerror = function(evt) { onError(evt) };

  function onOpen(evt)
    doSend("WebSocket rocks");

  function onClose(evt)

  function onMessage(evt)
    writeToScreen('<span style="color: blue;">RESPONSE: ' +'</span>');

  function onError(evt)
    writeToScreen('<span style="color: red;">ERROR:</span> ' +;

  function doSend(message)
    writeToScreen("SENT: " + message);

  function writeToScreen(message)
    var pre = document.createElement("p"); = "break-word";
    pre.innerHTML = message;

  window.addEventListener("load", init, false);


  <h2>WebSocket Test</h2>

  <div id="output"></div>
    is powered by Kaazing © | Copyright | All Rights Reserved.