Skip to content

Instantly share code, notes, and snippets.

@anurse anurse/.gitignore
Created Aug 31, 2016

Embed
What would you like to do?
WebSocket Repro Client
node_modules/
const WebSocketClient = require('websocket').client;
var url = process.argv[2]
if(!url) {
console.error("Usage: " + process.argv[0] + " " + process.argv[1] + " <WS URL>");
process.exit(1);
}
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function(connection) {
console.log('WebSocket Client Connected');
connection.on('error', function(error) {
console.log("Connection Error: " + error.toString());
});
connection.on('close', function() {
console.log('echo-protocol Connection Closed');
});
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log("Received: '" + message.utf8Data + "'");
}
});
connection.sendUTF("Hello, World");
connection.socket.end();
});
client.connect(url);
{
"name": "websockettester",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"websocket": "^1.0.23"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.