Git Product home page Git Product logo

websocket-bench's Introduction

websocket bench Build Status

Nodejs cli tool for benchmarking websocket servers. Currently supports:

Installation

npm install -g websocket-bench

Running Tests/Linting

First Install required dev-dependencies npm install Run Gulp Build Tool gulp mocha

Usage

Tip: You may find it useful to increase the maximum number of open file descriptors on your system during testing:

ulimit -n 60000

Simple example (using Socket.IO by default):

websocket-bench -a 2500 -c 200 http://localhost:3000

Simple example (using Primus):

websocket-bench -t primus ws://localhost:8080

command help

Usage: websocket-bench [options] <server>

Options:

  -h, --help               Output usage information
  -V, --version            Output the version number
  -a, --amount <n>         Total number of persistent connection, Default to 100
  -c, --concurency <n>     Concurent connection per second, Default to 20
  -w, --worker <n>         Number of worker(s)
  -g, --generator <file>   Js file for generate message or special event
  -m, --message <n>        Number of message for a client. Default to 0
  -o, --output <output>    Output file
  -t, --type <type>        Type of websocket server to bench(socket.io, engine.io, faye, primus, wamp). Default to socket.io
  -p, --transport <type>   Type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). Default to websockets (Just for Primus)
  -k, --keep-alive         Keep alive connection
  -v, --verbose            Verbose Logging

Benchmark message

For benchmark message or more advanced connection you should provide your own generator

generator structure :

    module.exports = {
       /**
        * Before connection (optional, just for faye)
        * @param {client} client connection
        */
       beforeConnect : function(client) {
         // Example:
         // client.setHeader('Authorization', 'OAuth abcd-1234');
         // client.disable('websocket');
       },

       /**
        * On client connection (required)
        * @param {client} client connection
        * @param {done} callback function(err) {}
        */
       onConnect : function(client, done) {
         // Faye client
         // client.subscribe('/channel', function(message) { });

         // Socket.io client
         // client.emit('test', { hello: 'world' });

         // Primus client
         // client.write('Sailing the seas of cheese');

         // WAMP session
         // client.subscribe('com.myapp.hello').then(function(args) { });

         done();
       },

       /**
        * Send a message (required)
        * @param {client} client connection
        * @param {done} callback function(err) {}
        */
       sendMessage : function(client, done) {
         // Example:
         // client.emit('test', { hello: 'world' });
         // client.publish('/test', { hello: 'world' });
         // client.call('com.myapp.add2', [2, 3]).then(function (res) { });
         done();
       },

       /**
        * WAMP connection options
        */
       options : {
         // realm: 'chat'
       }
    };

See also

French article about websocket-bench : Benchmarking websockets avec Node.Js

websocket-bench's People

Contributors

balaphp avatar mbilbille avatar nchaulet avatar patspam avatar pronskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-bench's Issues

duration

can you tell me more specific what is duration report mean. because the result when i try to make connection with 1 client is similar with when i make connection with 100 client which is about 600ms. if that is average time to make connection and if 100 client is just need 6ms for each 1 client, so why for 1 clien need 600ms??

Primus with engine.io is not working

i have created primus server app with engine.io then i tested with benchmark tool. All the request are failed (i set -t primus). After that i changed transport to websocket in primus then its working. how can i do the same test with primus engine.io.

Undefined method Monitor.isRunning()

The interrupt handler tries to call bench.monitor.isRunning() which isn't defined anywhere:

websocket-bench -t faye -a 3500 -c 50 ws://localhost:3100/faye
Launch bench with 3500 total connection, 50 concurent connection
0 message(s) send by client
1 worker(s)
WS server : faye
^C
Gracefully stoping worker from SIGINT (Ctrl+C)
/usr/local/lib/node_modules/websocket-bench/index.js:102
    if (bench.monitor.isRunning()) {
                      ^
TypeError: undefined is not a function
    at null._onTimeout (/usr/local/lib/node_modules/websocket-bench/index.js:102:23)
    at Timer.listOnTimeout (timers.js:119:15)

socket.io 1.0

was working before, now errors with socket.io 1.0

Custom generator debug

Hi,

I am trying to play with a custom generator to pass a session id cookie to Socket IO client for the handshake auth.

   beforeConnect : function(client) {
     // Example:
     // client.setHeader('Authorization', 'OAuth abcd-1234');
     logger.info(client);
     client.setHeader('cookie', 'sessionid;i6cmr55hgo6jmq6hz28ad2fcxxxxxxx');
   },

logger.info does not seem to output anything and I do not get any headers added on the sever side. As if the generator.js file was not taken into account.

I even tried to edit /usr/local/lib/node_modules/websocket-bench/lib/generator.js
PS:

 Benchmark Options {"generatorFile":"/usr/local/lib/node_modules/websocket-bench/lib/generator.js","type":"socket.io","logging":true}

Question - Support xhr-polling?

It is not the purpose of this benchmark tool but did you ever try to make it work with other transports like xhr-polling?

Its not closing opened ports after its done

Run this command to get opened port

netstat -an | grep -e tcp -e udp | wc -l

Then run load test, eg:

websocket-bench -t primus -p websockets -a 2000 -c 100 -v -w 1 ws://xxx.xxx.xxx.xxx:80

Then again check your open ports using above command (After load test is done completely).
You will find that roughly 2000 ports have been opened and not closed since last run of this command.

If I run load test multiple times I start getting

Primus Worker error{"code":"EADDRNOTAVAIL","errno":"EADDRNOTAVAIL","syscall":"connect","target":{"domain":null,"_events":{},"_maxListeners":10,"_socket":null,"_ultron":null,"_closeReceived":false,"bytesReceived":0,"readyState":3,"supports":{"binary":true},"extensions":null,"_isServer":false,"url":"ws://xxx.xxx.xxx.xxx:80/primus","protocolVersion":13,"binaryType":"arraybuffer","_closeTimer":null}}

Example from my machine:

[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
20
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
20
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
20
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
20
[[email protected] home]$ websocket-bench -t primus -p websockets -a 2000 -c 100 -v -w 1 ws://xxx.xxx.xxx.xxx:80
Launch bench with 2000 total connection, 100 concurent connection
0 message(s) send by client
1 worker(s)
WS server : primus
Benchmark Options {"generatorFile":"/usr/lib/node_modules/websocket-bench/lib/generator.js","type":"primus","transport":"websockets","verbose":true}
trying : 100 ...
trying : 200 ...
trying : 300 ...
trying : 400 ...
trying : 500 ...
trying : 600 ...
trying : 700 ...
trying : 800 ...
trying : 900 ...
trying : 1000 ...
trying : 1100 ...
trying : 1200 ...
trying : 1300 ...
trying : 1400 ...
trying : 1500 ...
trying : 1600 ...
trying : 1700 ...
trying : 1800 ...
trying : 1900 ...
trying : 2000 ...

#### steps report ####
┌────────┬─────────────┬────────┬──────────────┐
│ Number │ Connections │ Errors │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┤
│ 100    │ 100         │ 0      │ 598          │
├────────┼─────────────┼────────┼──────────────┤
│ 200    │ 100         │ 0      │ 523          │
├────────┼─────────────┼────────┼──────────────┤
│ 300    │ 100         │ 0      │ 505          │
├────────┼─────────────┼────────┼──────────────┤
│ 400    │ 100         │ 0      │ 509          │
├────────┼─────────────┼────────┼──────────────┤
│ 500    │ 100         │ 0      │ 506          │
├────────┼─────────────┼────────┼──────────────┤
│ 600    │ 100         │ 0      │ 509          │
├────────┼─────────────┼────────┼──────────────┤
│ 700    │ 100         │ 0      │ 516          │
├────────┼─────────────┼────────┼──────────────┤
│ 800    │ 100         │ 0      │ 505          │
├────────┼─────────────┼────────┼──────────────┤
│ 900    │ 100         │ 0      │ 505          │
├────────┼─────────────┼────────┼──────────────┤
│ 1000   │ 100         │ 0      │ 513          │
├────────┼─────────────┼────────┼──────────────┤
│ 1100   │ 100         │ 0      │ 507          │
├────────┼─────────────┼────────┼──────────────┤
│ 1200   │ 100         │ 0      │ 506          │
├────────┼─────────────┼────────┼──────────────┤
│ 1300   │ 100         │ 0      │ 507          │
├────────┼─────────────┼────────┼──────────────┤
│ 1400   │ 100         │ 0      │ 505          │
├────────┼─────────────┼────────┼──────────────┤
│ 1500   │ 100         │ 0      │ 504          │
├────────┼─────────────┼────────┼──────────────┤
│ 1600   │ 100         │ 0      │ 505          │
├────────┼─────────────┼────────┼──────────────┤
│ 1700   │ 100         │ 0      │ 504          │
├────────┼─────────────┼────────┼──────────────┤
│ 1800   │ 100         │ 0      │ 507          │
├────────┼─────────────┼────────┼──────────────┤
│ 1900   │ 100         │ 0      │ 508          │
├────────┼─────────────┼────────┼──────────────┤
│ 2000   │ 100         │ 0      │ 507          │
└────────┴─────────────┴────────┴──────────────┘
#### total report ####
┌────────┬─────────────┬────────┬──────────────┬──────────────┬──────────────┐
│ Number │ Connections │ Errors │ Message Send │ Message Fail │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┼──────────────┼──────────────┤
│ 2000   │ 2000        │ 0      │ 0            │ 0            │ 19521        │
└────────┴─────────────┴────────┴──────────────┴──────────────┴──────────────┘
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019
[[email protected] home]$ netstat -an | grep -e tcp -e udp | wc -l
2019

how to test engineio?

appledeMacBook-Pro-2:websocket ruandao$ websocket-bench -g generator.js -t engine.io -a 100 -c 40 http://localhost:5000/engine.io/
Launch bench with 100 total connection, 40 concurent connection
0 message(s) send by client
1 worker(s)
WS server : engine.io
/usr/local/lib/node_modules/websocket-bench/lib/worker.js:36
var worker = new BenchmarkWorker(server, generator, verbose);
             ^

TypeError: BenchmarkWorker is not a function
    at Object.<anonymous> (/usr/local/lib/node_modules/websocket-bench/lib/worker.js:36:14)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: channel closed
    at ChildProcess.target.send (internal/child_process.js:523:16)
    at Benchmark._nextStep (/usr/local/lib/node_modules/websocket-bench/lib/benchmark.js:87:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/websocket-bench/lib/benchmark.js:100:13)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

Using as node module export

I would like to use this project as a node module so I can have more control but that would change the existing implementation a bit.

I propose that a new library is created websocket-benchmarker which will contain the main logic and export all the "core" libraries.

This module can depend on the websocket-benchmarker module (to be created) and the commander script will reference the exported module.

I already have this working in a branch export-app but would need to separate the core library out to another repository, so it can still be used as a cli tool.

Check it out here:
https://github.com/iamchrismiller/websocket-bench/tree/export-app

This required me to clean up the process variable leaking into a few places it doesn't need to be and is now passed in to the constructors.

I will write some tests expecting the module is exporting all the required libs correctly and a bit more cleanup this weekend.

Let me know what you think.

I tested socket.io with websocket-bench both on Windows and Ubuntu, why did it got difference performance?

On Windows:
I installed websocket-bench 0.0.3, I tried to test total 6000 connections and concurrent connection per second is 100, in the total report, the duration is 60 seconds.

total report

┌────────┬─────────────┬────────┬──────────
│ Number │ Connections │ Errors │ Message Send │ Message Fail │ Duration(ms) │
├────────┼─────────────┼────────┼──────────
│ 6000 │ 6000 │ 0 │ 0 │ 0 │ 60086 │
└────────┴─────────────┴────────┴──────────

On Ubuntu: (4-core, 4G)
I installed websocket-bench 0.0.3 too. At the first time, I tried to test total 6000 connections and concurrent connection per second is 100, there are only around 4000 connection are successful, rest connections failed because connection timed out (over than 20 seconds).
I just changed the property 'timeout' for the connection from 20s to 50s in manage.js, so all connections are successful. The manage.js is in my path: /usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/lib/manage.js
In the total report, the duration is around 94 seconds.

total report

┌────────┬─────────────┬────────┬──────────────┬──────────────┬──────────────┐
│ Number │ Connections │ Errors │ Message Send │ Message Fail │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┼──────────────┼──────────────┤
│ 6000 │ 6000 │ 0 │ 0 │ 0 │ 94444 │
└────────┴─────────────┴────────┴──────────────┴──────────────┴──────────────┘
The cpu of nodejs was not high, it kept around 40% - 50% during connecting.

Why was it so slow on Ubuntu when cpu was not high?
Could you please help me?
Thanks in advance.

how to use

how to test my project

I'm a noob..
I user websocket-bench to test my project with command
websocket-bench -a 10000 -c 1000 -g ../lib/generator.js -k http://***.cn
and sometimes i got some tables named '#### steps report ####' , is it the final log of this test?

usage of 'onConnect' and 'sendMessage'

my generator.js
onConnect : function (client, done) { client.emit('sign', {uid: 'bench_1' , nickName: 'nickName:2'}); done(); }, sendMessage : function (client, done) { logger.error('Not implement method sendMessage in generator'); client.emit('message', {text: 'text: 1' , nickName: 'nickName:'+ 2}); done(); }
and why my project got no message on console?

please help..

socket.io transport error

command i have used: websocket-bench -a 100000 -c 10000 -w 4 {url}
/usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/lib/socket.js:281
self.transport.onClose();
^
TypeError: Cannot call method 'onClose' of null
at null._onTimeout (/usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/lib/socket.js:281:22)
at Timer.listOnTimeout as ontimeout

/usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/lib/socket.js:281
self.transport.onClose();
^
TypeError: Cannot call method 'onClose' of null
at null._onTimeout (/usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/lib/socket.js:281:22)
at Timer.listOnTimeout as ontimeout

SocketIO Worker error: {"type":"TransportError","description":400}

Hi, I have this error when execute the websocket-bench...

_> websocket-bench -a 40 -c 10 -p websockets -t socket.io 'https://netbar.com:9876' -v

Launch bench with 40 total connection, 10 concurent connection
0 message(s) send by client
1 worker(s)
WS server : socket.io
Benchmark Options {"generatorFile":"/usr/local/lib/node_modules/websocket-bench/lib/generator.js","type":"socket.io","transport":"websockets","verbose":true}
trying : 10 ...
SocketIO Worker error: {"type":"TransportError","description":400}
SocketIO Worker error: {"type":"TransportError","description":400}
....

npm install failure

Hi, I've tried install websocket-bench use npm.
I've got some errors ,it seems that the reason is
http fetch 404 http://github.com/component/emitter/archive/1.0.1.tar.gz .

 npm WARN deprecated [email protected]: This project has been renamed to extendible. This project will not receive any updates anymore
npm ERR! fetch failed http://github.com/component/emitter/archive/1.0.1.tar.gz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm WARN deprecated [email protected]: use uuid module instead
npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.11.3"})
npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.11.3"})
npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.11.3"})
npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.11.3"})
npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.11.3"})
npm ERR! fetch failed http://github.com/component/emitter/archive/1.0.1.tar.gz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404

> [email protected] install /usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil
> node-gyp rebuild

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9

> [email protected] install /usr/local/lib/node_modules/websocket-bench/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate
> node-gyp rebuild

  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9

> [email protected] install /usr/local/lib/node_modules/websocket-bench/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate
> node-gyp rebuild

  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9

> [email protected] install /usr/local/lib/node_modules/websocket-bench/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil
> node-gyp rebuild

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9
npm ERR! fetch failed http://github.com/component/emitter/archive/1.0.1.tar.gz
npm ERR! Darwin 15.6.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "websocket-bench"
npm ERR! node v0.12.2
npm ERR! npm  v2.11.3

npm ERR! fetch failed with status code 404
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/wenter/npm-debug.log

The debug log :


9272 info attempt registry request try #1 at 17:12:32
9273 http fetch GET http://github.com/component/emitter/archive/1.0.1.tar.gz
9274 http fetch 404 http://github.com/component/emitter/archive/1.0.1.tar.gz
9275 error fetch failed http://github.com/component/emitter/archive/1.0.1.tar.gz
9276 verbose about to build /usr/local/lib/node_modules/websocket-bench/node_modules/engine.io-client
9277 verbose unlock done using /Users/wenter/.npm/_locks/engine-io-client-66ea7499c19d7102.lock for /usr/local/lib/node_modules/websocket-bench/node_modules/engine.io-client
9278 verbose about to build /usr/local/lib/node_modules/websocket-bench
9279 verbose unlock done using /Users/wenter/.npm/_locks/websocket-bench-f4b68275b6acba70.lock for /usr/local/lib/node_modules/websocket-bench
9280 verbose stack Error: fetch failed with status code 404
9280 verbose stack     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/fetch.js:51:14)
9280 verbose stack     at Request.emit (events.js:107:17)
9280 verbose stack     at Request.onRequestResponse (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1142:10)
9280 verbose stack     at ClientRequest.emit (events.js:107:17)
9280 verbose stack     at HTTPParser.parserOnIncomingClient (_http_client.js:426:21)
9280 verbose stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
9280 verbose stack     at Socket.socketOnData (_http_client.js:317:20)
9280 verbose stack     at Socket.emit (events.js:107:17)
9280 verbose stack     at readableAddChunk (_stream_readable.js:163:16)
9280 verbose stack     at Socket.Readable.push (_stream_readable.js:126:10)
9281 verbose cwd /Users/wenter
9282 error Darwin 15.6.0
9283 error argv "node" "/usr/local/bin/npm" "install" "-g" "websocket-bench"
9284 error node v0.12.2
9285 error npm  v2.11.3
9286 error fetch failed with status code 404
9287 error If you need help, you may report this error at:
9287 error     <https://github.com/npm/npm/issues>
9288 verbose exit [ 1, true ]

much thanks .

SocketIO Worker error

When i run the sh script:

websocket-bench -a 1000 -c 100 -w 5 -p websocket -g websocket-bench.js -m 5 -v http://10.10.53.53:8001

The Error Appear! Is it a bug?

SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}
SocketIO Worker error: {"code":"parser error"}

why does the generator.js sendMessage not work

code like this :

module.exports = { beforeConnect : function (client) { }, onConnect : function (client, done) { client.emit('sendMsg', { hello: 'world' }); done(); }, sendMessage : function (client, done) { client.emit('sendMsg', { hello: 'world' }); done(); } };

when i emit msg in onConnect fun it works, but in sendMessage function it does not work ? why

Feature : Allow configuration options to be passed into Client constructor

It would be nice to be able to allow Client constructor options. We would have to define the default options block for each worker since they will all be different and validate against bad options.

Maybe we can define a config json with a parameter

-e Environment Config

env-socketio.js

{
   "connect timeout" : 2000,
   "reconnection delay" : 200
} 

Feature : Implement Grunt/Gulp Support

It would be nice to run the tasks when developing against this library

  1. jslint
  2. complexity
  3. mocha test

I wouldn't mind implementing it. I'm just curious if you have a preference for the Build System.

no method 'subscribe'

When I run

$ node index.js -a 1 -c 1 http://localhost:3000

I get

/Users/guille/stress/original/lib/generator.js:23
client.subscribe('http://127.0.0.1/', function() {});
^
TypeError: Object # has no method 'subscribe'
at Object.exports.onConnect (/Users/guille/stress/original/lib/generator.js:23:10)
at BaseWorker._onClientCreation (/Users/guille/stress/original/lib/workers/baseworker.js:78:29)
at /Users/guille/stress/original/lib/workers/baseworker.js:34:23
at SocketNamespace. (/Users/guille/stress/original/lib/workers/socketioworker.js:21:4)
at SocketNamespace.EventEmitter.emit as $emit
at SocketNamespace.onPacket (/Users/guille/stress/original/node_modules/socket.io-client/lib/namespace.js:152:14)
at Socket.onPacket (/Users/guille/stress/original/node_modules/socket.io-client/lib/socket.js:443:30)
at Transport.onPacket (/Users/guille/stress/original/node_modules/socket.io-client/lib/transport.js:98:17)
at Transport.onData (/Users/guille/stress/original/node_modules/socket.io-client/lib/transport.js:69:16)
at WebSocket.websocket.onmessage (/Users/guille/stress/original/node_modules/socket.io-client/lib/transports/websocket.js:73:12)

Testing req-rep patterns

Hello, I am trying to test req-rep patterns using ws socket.io, but the benchmark generator I wrote does not work:

server

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res) {
    res.sendfile(__dirname  + '/index.html');
});

io.on('connection', function(socket) {
    socket.on('req', function() {
        socket.emit('ans', 'hello');
    });
});

http.listen(3000, function() {
    console.log('listening on *:3000');
});

generator.js

    /**
     * Send a message (required)
     * @param {client} client connection
     * @param {done} callback function(err) {}
     */
    sendMessage : function(client, done) {
        client.on('ans', function() {
            done();
        });
        client.emit('req', 'hello');
    },

Why is that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.