0

I set up node.js on my laptop and I am testing.

I need to test a scenario where server sends data to all the clients and another scenario where server sends data to a specific client.

How can I emulate "many clients - one server" on my laptop, before I publish the project ?

Opening many different browsers (IE,Firefox,Chrome) and connecting them on the same URL will do the trick , or I need a special set-up or software?

Thanks

user2860857
  • 549
  • 3
  • 10
  • 21

1 Answers1

0

You can create your server and then other node scripts that connect to the server via a http request. Here is an example how you can connect to a node server API:

var http = require('http'); 
   var options = {
                port: 80,
                path: '/path/yourMethod/?Parameter1=7&Parameter2=8',
                method: 'GET',
            };

            var req = http.request(options, function(res) {
                res.on('data', function (data) {
                    data = JSON.parse(data);
                    console.log(data);
                });
            });

You need to include the http package for that.

So you can connect to the server and emulate clients. Hope that helped.

bdifferent
  • 703
  • 4
  • 12
  • Yes, but this is just a part of an http node server, the basic one. My problem is how to virtually have many clients talking with the same server , on the same physical laptop. – user2860857 Dec 22 '15 at 16:31