How do I prevent a PubNub socket connection from aborting when my Android phone goes to sleep?

Your Android app can continue to receive messages while in background mode. The connection can even stay open when the phone goes to sleep, as long as you set the partial wake lock.