Forum Cross Platform with Xamarin

Socket Connection to Server when App is in Background

1. Mobile Client uses Xamarin Native as a technology.
2. I have a Mobile Client which uses a PCL that performs the socket connection to remote server.
3. All communications to the remote server are only thru the PCL’s socket based connection.

1. The Mobile client needs to maintain the connection to the remote server whether its in the foreground or the background
2. The reason it needs the connection when it is in background is to update the Remote Server about its geo-position.

Current Problem:
Once the app goes into the background, the app loses the socket connection.

Suggestion Required for :
1. What is the best way to keep the connection active to the remote server, even when the Mobile Client is in the background.
2. How should I implement this solution for the best performance?
3. Any code snippets will help?



  • AlexWhiteAlexWhite GBMember ✭✭✭
    Your requirement of maintaining a commection to the server won’t happen in a mobile app, your design must deal with the reality that connections are going to get broken and frquently, you must deal with tha with retries on the connection.

    From experence of coding sockets v webapi if you can work on connecting via webapi and shipping your location that way you will save yourself a lot of trouble, Not all telcos fully implement sockets or websockets on their networks but all cope with http / webapi ok.
  • Thanks for the reply. The remote server is my own server. Not any 3rd party servers. I need to maintain connection to my server when the mobile app is in the background.

Sign In or Register to comment.