1

I am using a simple node.js server to broadcast messages:

var ws = require('websocket.io');
var server = ws.listen(3000);
server.on('connection', function(socket) {
        socket.on('message', function(data) {
                server.clients.forEach(function(client) {
                        client.send(data);
                });
        });
});

The client is written in c++ (cocos2dx framework) and it's working like this:

_websocket = new WebSocket();
_websocket->init(*this, "ws://localhost:3000");
....
_websocket->send(message);

When I measure the latency by sending something to the server and waiting for the response: it's around 80-100ms. The node.js server runs on localhost and I would expect the ping to be around 0-10ms max. Do you know the reason why the ping is so high? Do I have to flush something or is something wrong with the server setup?

Thanks!

Tony Babarino
  • 3,355
  • 4
  • 32
  • 44
badmonkee
  • 19
  • 2
  • I haven't used the framework that you are using but I have used the `CometD` implementation in Java. There were a lot of parameters for things like buffering, message packing etc... that had a large effect on the system performance. I suggest that you post your config. Also don't overly invest in optimising a `ping`... that is hardly going to be close to your real use case. – Dennis Apr 18 '16 at 11:01
  • apperently this is something cocos2dx or websockets related. i did the same test but with an java server implementation of websockets with the same result. node.js is not the problem. if anyone knows what configs i need to change in order to make the ping go under 10ms, please let me know :) – badmonkee Apr 18 '16 at 13:25
  • Do you have front end web server like Apache in your stack? – Donghwan Kim Apr 23 '16 at 15:25

0 Answers0