mqttjs / MQTT.js

The MQTT client for Node.js and the browser
Other
8.57k stars 1.42k forks source link

examples #91

Closed Kenzku closed 11 years ago

Kenzku commented 11 years ago

How does your example work?

I tried client_test.js with server orig.js Then I simply added a subscribe function in connack on the client side:

client.subscribe('test0',null,function(){
         console.log('I am subscribe');
      });

but the problem is, it seems the orig.js cannot capture this subscription, i.e. if I put a console.log in orig.js, this function is not called:

client.on('subscribe', function(packet) {
      console.log('I receive it');
      var granted = [];
      ...
  });
adamvr commented 11 years ago

client_test.js and evict.js are cruft that are left over from the old api. They're gone now. What are you trying to do?

Kenzku commented 11 years ago

I tried to measure the message overhead comparing with other Pub/Sub protocols, by using your mqtt library. I want to use a client to subscript a topic, then publish an event with the same topic and the server should return the event back to the client.

Can you link me to a version that will work please?

adamvr commented 11 years ago

Check out examples/client now. If you're benchmarking, I wouldn't use the server examples. They're 5 minute hacks and are by no means optimised. It would be best if you ran up your own instance of mosquitto and tested against that.

Kenzku commented 11 years ago

yes, I found out something new. Can the client run constantly? (Did you talk about the mosquitto tested server?)

adamvr commented 11 years ago

The client will run until you call #end() on it. You can find mosquitto at http://mosquitto.org and there's a test mqtt server running on test.mosquitto.org. So you can connect to it using mqtt.createClient(1883, 'test.mosquitto.org')

Kenzku commented 11 years ago

I could not use a server over the Internet, otherwise the tests are not running on the same level. I think I will use your server instead.