Xamarin Troubleshooting: offline sync issues against Azure App Service using WireShark

Introduction

Azure App Service is one of common options to integrate with as a back-end service, It provides several features including offline data syncing feature but troubleshooting data syncing failure issues will be difficult if you don't have access to service source-code or Xamarin App integrates with third-party service.

Solution

When Xamarin application sync with Azure App service, it sends series of HTTP requests to push local data changes to back-end and pull latest data changes from back-end.

Solution is to use network monitoring tool to analyze those HTTP requests/responses and get clear detailed information about many things like whether requests sent from mobile app contain invalid data or not, also get detailed information about any error messages included in HTTP responses (if any) and which tables failed to sync successfully.

WireShark is free widely-used network protocol analyzer used to monitor many protocols including HTTP. it can be installed on Windows and macOS and this is an advantage over Fiddler because currently (at the time of writing this post) there is no release build from Fiddler that supports macOS.

WireShark can be used to investigate network traffic between Xamarin application and Azure App Service.

How to configure WireShark

  • After launching WireShark, click "capture options" 

     icon in Application toolbar.

  • When "capture options" modal screen appears, select which network interface you need to monitor.

  • In "capture filter" text-box under "network interfaces list", type word "host" and mobile app service URL without protocol part. for example if your mobile app service URL is https://your-service.azurewebsites.net then type "host your-service.azurewebsites.net". this action will configure WireShark to capture only traffic targeting mobile app service.

  • Click "start" button, launch mobile application on simulator and initiate Sync operation.

  • After clicking "start" button, New window will appear and it will list all captured network packets including HTTP requests/responses.

  • Double-clicking any row will display detailed information about captured packet (request/response) in modal window.

  • WireShark provides search capabilities and ability to export captured data to different file formats.

  • Press "red square" icon to stop capturing network packets.

  • For more information about WireShark please refer to documentation.

Summary

Network monitoring tools like WireShark can help in troubleshooting data sync issues with third-party Azure App Service.