Skip to content

Instantly share code, notes, and snippets.

@CrackerHax
Last active November 17, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrackerHax/c0b0bd105ef44f06fb31 to your computer and use it in GitHub Desktop.
Save CrackerHax/c0b0bd105ef44f06fb31 to your computer and use it in GitHub Desktop.
A script to test your highfidelity websockets
var wsUri = "ws://echo.websocket.org";
var wssUri = "wss://echo.websocket.org";
var connection;
function load(uri) {
connection = new WebSocket(uri);
connection.onopen = function () {
var send = "Hello, world!";
print('Client (to '+uri+': ' + send);
connection.send(send);
};
connection.onerror = function (error) {
keepAlive = false;
connection.close();
print('WebSocket error: ' + error);
};
connection.onmessage = function (e) {
print('Server (from '+uri+': ' + e.data);
};
}
load(wsUri);
//load(wssUri);
@CrackerHax
Copy link
Author

use load(wsUri) to test unsecure websockets and load(wssUri) to test secure websockets.

It should echo back Hello, world! from the server. If it does not you need to figure out why your websockets are not working. It might be a firewall or network issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment