PubNub to Apply TimeToken Enhancement

3 min read Stephen Blum on Apr 22, 2012

PubNub is applying a TimeToken enhancement to our web-messaging infrastructure on May 2, 2012 .  If your app uses the PubNub TimeToken directly, then this article concerns you.

For the latest information please visit PubNub Help Desk and Knowledge Base.

Note that it is unusual  for you to be using the TimeToken directly so this message is just a precaution.  

Please feel free to ignore this announcement if you don’t use the TimeToken directly.

If you are using TimeToken directly this upgrade will need your prompt attention :

What do you need to do to keep your app running?  This upgrade will likely have no affect on your app. Greater than 99% of the cases you will not need to concern yourself with this upgrade.   We have already ensured your app will be compatible with all PubNub Client APIs/SDKs since version 3.0+.  However, if you make use of the PubNub TimeToken directly, then you may need to apply adjustments to your usage pattern.   If you don’t know what the TimeToken is then you most likely don’t need to do anything.

PubNub TimeToken Q&A

  1. When will this Enhancement go into Production?

May 2nd, 2012 at 11:00pm PDT.

  1. What is Changing?

This upgrade will increase the PubNub TimeToken longevity by four additional digits on the left side of the TimeToken number (prepend).

  1. Why is this needed?

The Original TimeToken was a smaller value; originally for optimal reasons.  However due to low cap value, the TimeToken resets to zero every fortnight  (14 days) which causes brief window of time where messages may be duplicated undesirably and only if previous messages existed in a channel’s queue before the rollover.

  1. When will the new TimeToken Reset?

The new Reset Date: 03:14:07 UTC on Tuesday, 19 January 2038 – read more –  However the PubNub TimeToken is a 64bit value that is ready for the new Unix Timestamp update to address the 2038 problem inherent with 32bit INT value max.

  1. If the New TimeToken is a larger value than can be held in a 32bit value, will this cause issues with my PubNub Client API?

No because the TimeToken is delivered as a “STRING”.

  1. How big was the original TimeToken?

The original TimeToken was 13 (thirteen) digit places.

  1. How big is the new TimeToken?

The new TimeToken is 17 (seventeen) digit places.

  1. How big is the difference between new and old TimeToken?

The difference is 4 (four) digit places.

  1. How do I convert the PubNub TimeToken into a Unix Timestamp?
// UNARY OP is used to convert a STRING to INT +
Unix TimeStamp = Math.ceil(+PubNub_TimeToken / 10000);

Convert PubNub TimeToken to a Unix Timestamp – Precaution! – This is a very large number and can only be contained by a 2-Long/Double/64bit Integer  value only.  Interpreting this big number into a standard 32bit int will cause bit overflow (byte wrap).

  1. Can I see an Example of the New and Old PubNub TimeToken?

Old:  “2013292485551”
New: “13341998516982484”

  1. How does the PubNub TimeToken differ from a Unix Timestamp?

Standard Unix Timestamps (example: 1334199851) are 10 Digits.  On May 2, 2012 the PubNub TimeToken will be 17 digits.