Do a FREE Echo Test for Websockets

First, you can do a HTML5 WebSocket test against the echo server. You can also test against your own server URL.

Afterwards, you can see a walkthrough for creating a WebSocket application yourself. We host a WebSocket Echo Server at wss://socketsbay.com/wss/v2/2/demo/

Of course, you can also inspect WebSocket messages using your browser.

Go ahead and try it out!

Try our advanced WebSockets server, available for everyone

     
                                

Instructions

Do please note, that in some environments the WebSocket connection may fail due to intermediary firewalls, proxies, routers etc.

Creating your own test

Using a plaintext editor, copy the following code and save it as websocket.html. Afterwards, simply open it in a browser. The page will automatically connect, send a message, echo the response, and close the connection.

<!DOCTYPE html>
  
  <head>
    <title>WebSocket client test</title>
  </head>

  <body>
    <h1>WebSocket Client Test</h1>
    <div id="log"></div>
  </body>

<script language="javascript" type="text/javascript">

    var wsUri = "wss://socketsbay.com/wss/v2/2/demo/";
    var log;

    function init()
    {
      log = document.getElementById("log");
      testWebSocket();
    }

    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)
    {
      writeLog("CONNECTED");
      sendMessage("Hello world");
    }

    function onClose(evt)
    {
      writeLog("Websocket DISCONNECTED");
    }

    function onMessage(evt)
    {
      writeLog('<span style="color: blue;">RESPONSE: ' + evt.data+'</span>');
      websocket.close();
    }

    function onError(evt)
    {
      writeLog('<span style="color: red;">ERROR:</span> ' + evt.data);
    }

    function sendMessage(message)
    {
      writeLog("SENT: " + message);
      websocket.send(message);
    }

    function writeLog(message)
    {
      var pre = document.createElement("p");
      pre.innerHTML = message;
      log.appendChild(pre);
    }

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

  </script>
  

If you continue to browse, we’ll use cookies that make our site work, improve performance, and customise your experience. If you accept, we’ll will not use cookies for ads.