5

I want to know who sent the messages when retrieved from the pubnub.history!

pubnub.history() only returns timetoken and the message.

Ash0ur
  • 1,505
  • 2
  • 8
  • 11

1 Answers1

3

PubNub Sender UUID: realtime vs history

The sender (publisher) UUID is provided in the message you receive in realtime as a subscriber, but PubNub only stores the actual message you published along with any meta data that provided:

PubNub JavaScript SDK publish docs sample code

pubnub.publish(
    {
        channel: 'my_channel',
        message: { 
            such: 'object'
        },
        meta: { 
            "cool": "meta"
        }
    }, 
    function (status, response) {
        if (status.error) {
            // handle error
            console.log(status)
        } else {
            console.log("message Published w/ timetoken", response.timetoken)
        }
    }
);

Best practice would be to add the publisher's UUID to the meta parameter which will not only allow you to get this value using history API, but you can also use it to filter out messages that the client has sent (don't receive your own messages using Stream Filter).

Community
  • 1
  • 1
Craig Conover
  • 4,710
  • 34
  • 59
  • I have tried that before, but only entry and timetoken I get ! – Ash0ur Jun 10 '18 at 21:12
  • Logs, I must see. Troubleshoot, I will. ;) If you can [enable PubNub client logging and reproduce the issue and send us the log results](https://www.pubnub.com/docs/web-javascript/pubnub-javascript-sdk-troubleshooting-guide), I can probably find the root cause. You can [send to PubNub Support](https://support.pubnub.com) and I will post back resolution here. Be sure to include this SO link when you contact us at support. – Craig Conover Jun 11 '18 at 16:25
  • Also, I think you are not understanding the different between the message and the metadata. – Craig Conover Jun 13 '18 at 19:31
  • I understand the difference, I'm currently using the metadata a lot, but It doesn't work in the history, anyway, I managed to get around this issue. – Ash0ur Jun 14 '18 at 12:03
  • Sure thing. Would like to know the solution/workaround and please file any issues with metadata not being stored or accessible in PubNub Storage with PubNub Support so we can fix anything that is not working as expected. – Craig Conover Jun 19 '18 at 00:06