The community forums are in BETA and closed to the public.

Getting response more than 1 time in javascript.( random behaviour of response)

Using JavaScript SDK we are creating two channels , 1 for request and another for response . But we are receiving more than 1 response for a request send. And when we see request/response in Google chrome console( we initialize Pubnub on Chrome) , it seems that response is coming only one time. Below is the call back function we are using.

var zigbee_devices_call =  function (JSONObj , callback) {
     pubnub = PUBNUB.init({                                  
         publish_key   : publish_key,
         subscribe_key : subscribe_key

         channel :  "response", 
         message : function(data){
         console.log( console.log(JSON.stringify(data)));
         connect: pub()

  function pub () {
             channel :  "request",
             message : JSONObj,
             callback: function(m){ console.log(m) }

PubNub may bundle multiple messages into a single "subscribe" response. The "message" function specified in pubnub.subscribe will be invoked for each published message:

It's handled here in the PubNub JS SDK:

It's also visible through the Subscribe REST API. The subscribe response is an array. The first element is an array of messages. The second is the timetoken to be used in the subsequent subscribe request.

This is a example subscribe response that contains two messages:


Comments to this discussion are now closed!