The short answer is that you're not going to be able to maintain the TCP session when the user does something to leave your application (whether user backs out of the app or launches some other app). You should look into an API that the server supports to resume an existing user chat session over a new TCP session. I don't know MQTT to provide more specifics on how to achieve this magic. But once you figure it out, you'll want to use that mechanism to try to resume an existing chat session in both your Application_Launching and Application_Activated events.
A BackgroundAgent cannot run more often than every 30 minutes (except when debugging), that isn't frequent enough to keep a TCP session alive.