What is a best practice for dealing with timeouts when publishing messages?

The best practice for handling a timeout on publishing a message is via an auto-retry:

doPublish = function(theChannel, theMessage) {
    pubnub.publish({
        "channel" : theChannel,
        "message" : theMessage,
        "callback" : function(m) {console.log("Successfully Sent Message!")},
        "error" : function(m) {
            console.log("Message send failed - [" 
                + JSON.stringify(m) + "] - Retrying in 3 seconds!");
            setTimeout(doPublish(theChannel, theMessage), 3000);
        }
    })
}