node.js - Connecting to socket.io 1.x manually using websockets, capacity testing -


i working nodejs express server uses socket.io communicate ios client, , having little trouble trying test how many clients can connect , exchange data @ 1 time.

my goal able run script connects socket.io thousands of different sessions, send , receive data understand our system's scale. using single dyno on heroku considering other options on aws soon.

i have found code should trying earlier versions of socket.io, such this, have had issues since seems v1.x has different handshake protocol. tried out using socket.io-client package, trying connect multiple times simulates use of 1 session, need simulate many in independent users.

i have been picking apart socket.io-client code, have gotten far creating connection - stuck on sending data part. if has knowledge or point written resources on how data sent between client , socket.io server, me out lot.

here's have far:

var needle = require('needle'),     websocket = require('ws'),     base_url = 'url-to-socket-host:5002';  var connectionno = 0; needle.get('http://' + base_url + '/socket.io/?eio=3&transport=polling&t=1416506501335-0',        function (err, resp) {      // parse sid     var resp = json.parse(resp.body.tostring().substring(5, resp.body.tostring().length));      // use sid connect using websockets     var url = 'ws://' + base_url + '/socket.io/?eio=3&transport=websocket&sid=' + resp.sid;     console.log(connectionno + ' sid: ' + resp.sid);     var socket = new websocket(url, void(0), {         agent: false     });      socket.on('open', function () {         console.log('websocket connected: ' + connectionno);          // don't understand how send data server here,         // looking @ source code should use kind          // of binary encoding, ideas?          socket.on('message', function (msg) {             console.log(msg);         });     }); }); 

i continue deconstructing socket.io-client code if has clues or recourses may help, let me know. thanks.

i ended setting using socket.io-client npm package has ability connect new session on every connection. found example benchmark in this issue.

there not need me manually connect socket.io using pure websockets , http, yannik pointing out parser in use. spec of inner workings of v1.x can found here.

thanks!


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -