Skip to content

Instantly share code, notes, and snippets.

@leedm777
Created February 18, 2015 22:06
Show Gist options
  • Save leedm777/ba6d86468d7646073286 to your computer and use it in GitHub Desktop.
Save leedm777/ba6d86468d7646073286 to your computer and use it in GitHub Desktop.
Slam asterisk with large frames over the websocket
/*
* - must be run on a different machine than the one that runs Asterisk
* - npm instal ws
* - change <asterisk-host> to the IP/hostname of the Asterisk box
* - node asterisk-ws-slam.js
*/
var WebSocket = require('ws');
var ws = new WebSocket('ws://<asterisk-host>:8088/ws', { protocol: 'echo' });
var str = new Array(16384 - 10).join('x');
var count = 0;
ws.on('open', send);
function send() {
ws.send(str);
}
ws.on('message', function(message) {
console.log('rxed', ++count);
if (message === str) {
send();
} else {
console.error('Unexpected text:', message);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment