Last active
November 17, 2015 22:10
-
-
Save CrackerHax/c0b0bd105ef44f06fb31 to your computer and use it in GitHub Desktop.
A script to test your highfidelity websockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.