Test Your Sockets

This web site uses WebSockets, looking at the technology that's natively available in this particular browser it doesn't look like you've got native support baked in. Sorry no dice for you today :(

Web Socket live testing

This is all the JavaScript you need to start using real-time messaging on your site today:

var output = document.getElementById('output');
function message(str) {
  var li = document.createElement('li');
  output.appendChild(li.appendChild(document.createTextNode(str)));
  output.scrollTop = output.scrollHeight; // scroll to end
}
 
var socket = new WebSocket('ws://testyoursockets.com');
 
socket.onopen = function () {
  message('Connected');
};
 
socket.onmessage = function (event) { 
  message('Message: ' + event.data);
}

Here's a server for you to experiment with

This example server is listening for connections which you're welcome to test out in your own code. You can also test calls by either posting or getting the test url.

Type a message in the box on the right and watch your message be distributed to every who is connected. Also, if you fancy some command line action, you can post a message directly from your command line and it will be pushed to this web page in real time - give it a try using this:

curl --data "Hello world" http://testyoursockets.com/test

You can also create your own web page to connect to this WebSocket example and other people will see your messages come in.

Creating your own server

This example is running using Node.js and if you want to give it a try I've uploaded the code for your helping. Grab it from github and have a play and enjoy. Equally, you can use a server like Twisted if Node isn't your cup of tea.

Download the example server code

Learning Resources

Supported By