Added error handling for packet and fog server.