Created
February 18, 2015 22:06
-
-
Save leedm777/ba6d86468d7646073286 to your computer and use it in GitHub Desktop.
Slam asterisk with large frames over the websocket
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
/* | |
* - 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