Answer the question
In order to leave comments, you need to log in
Load testing Socket.IO / SockJS?
Hello.
Can you please tell me how to test NodeJS + Websockets (Socket.IO/SockJS)?
On a small Ubuntu 14.04 LTS server, NodeJS 4.4.4 is installed and 2 applications are running on port 8081 on Express + Socket.IO and SockJS. It is necessary to check that everything is working fine + check how the application will behave under load (at least 100 simultaneous connections). At this stage, the application is very simple like Hello World, but things will gradually get more complicated. The client simply connects to the socket and prints all messages to the console.
server.js (SockJS) code:
var http = require('http');
var sockjs = require('sockjs');
var echo = sockjs.createServer({ sockjs_url: 'http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js' });
echo.on('connection', function(socket) {
socket.write('connected');
socket.write('Hello world');
socket.on('close', function() {
socket.write('disconnected');
});
});
var server = http.createServer();
echo.installHandlers(server, {prefix:'/websocket'});
server.listen(8081, '0.0.0.0');
var express = require('express')();
var http = require('http').Server(express);
var io = require('socket.io')(http, {path: '/websocket'});
io.on('connection', function (socket) {
io.emit('message', 'connected');
io.emit('message', 'Hello world');
});
express.get('/index.html', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
express.get('/socket.io.js', function (req, res) {
res.sendFile(__dirname + '/socket.io.js');
});
http.listen(8081, '0.0.0.0');
/home/n****t/wsbench/lib/optparse.js:144
while(l--> 0) if(LONG_SWITCH_RE(arr[l])) return true;
^
TypeError: object is not a function
at contains_expr (/home/nan***1t/wsbench/lib/optparse.js:144:23)
at build_rules (/home/n**m1t/wsbench/lib/optparse.js :77:13)
at Object.OptionParser.parse(/home/nan**t/wsbench/lib/optparse.js:224:21)
at Object. (/home/n*****t/wsbench/wsbench:113:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10 )
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
Connecting to ws://******.net:8081/websocket
Online 618 milliseconds
Time taken 618 milliseconds
Connected 0
Disconnected 0
Failed 1
Total transferred 0B
Total received 0B
Durations (ms): min mean stddev median max
Handshaking NaN NaN NaN NaN NaN
Latency NaN NaN NaN NaN NaN
Percentile (ms): 50% 66% 75% 80% 90% 95% 98% 98% 100%
Handshaking NaN NaN NaN NaN NaN NaN NaN NaN NaN
Latency NaN NaN NaN NaN NaN NaN NaN NaN NaN
Received errors:
1x socket hang up
Answer the question
In order to leave comments, you need to log in
https://gist.github.com/S-anasol/3eaf154e2beb5ca1c...
Here is an example for socket.io
1. Install the required websocket client for nodejs
2. Write a script that makes the required number of connections
3. ...
4. Profit
https://github.com/observing/thor
Here is a ready tool for loading Websocket. I think to fasten it to Socketio is not a problem.
Installed on ubuntu socket io in Laravel project.
How to find out what port the socket server is running on? default like 80
But application throws GET laravel/socket.io 404 Not Found
Yes. there is a kind of application that combines Habr, Geek and Megamind
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question