Created
August 31, 2016 21:30
-
-
Save analogrelay/fe87ecf8aa01832a99dd247c64cb4595 to your computer and use it in GitHub Desktop.
WebSocket Repro Client
This file contains hidden or 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
node_modules/ |
This file contains hidden or 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
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); |
This file contains hidden or 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
{ | |
"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