Fixed possible CME due to pending packets
Expanded the try catch for publish to prevent larger crashes