How to Troubleshoot Network Requests in iOS MABS 6 Builds

With MABS 6.0 Beta 1 and the introduction of the WkWebview and the Nitro Engine, we’ve gained faster iOS mobile applications.

However, in the process, we lost our ability to troubleshoot network requests, and the Safari Web Inspector no longer shows Network information about Server Actions requests (MABS 6.0 Breaking Changes and Known Limitations).

Today we’d like to share with you an alternative to Safari’s inspector, and how you troubleshoot these applications.

In this example, we’re going to use mitmproxy, an open-source man-in-the-middle proxy for HTTP and HTTPS with both console and web-based interfaces. 

If you have the proxy set up, you’ll just need to configure the device to get it to work. Otherwise, you’ll first have to set up the proxy, which you can find the instructions for here.


Configuring HTTP Proxy in the device

  1. Access Settings > Wi-Fi and select the current connection to access its detail:

  2. Scroll down, and select the “Configure Proxy” option:

  3. Choose the “Manual” option, enter the proxy machine’s IP and Port (for example 192.168.1.128:8080), and hit “Save”:

  4. From here on out, all the requests are going to be routed through your proxy.

 

Install mitmproxy certificate

  1. For this solution to work, you’ll need the proxy certificate to be installed on your device. So let’s access mitm.it in the device’s Safari Browser;

  2. Here, you’ll be presented with the option to download the certificate:

  3. Once the certificate is downloaded, go to the Settings app, and select the “Profile Downloaded” option:
     

  4. Install the certificate:

  5. Now, go to Settings > General > About > Certificate Trust Settings.

  6. Under “Enable full trust for root certificates”, turn on trust for the mitmproxy certificate.

And you’re done! HTTP requests generated from your app will now be visible here. If you’re looking to use this with SSL Pinning configured on your app, make sure you add the new certificate returned for your app’s server to its configuration.

 

Unlike Safari, with this setup, we can also manipulate requests. Here’s how to intercept specific requests:


Intercept network requests

  1. Now that the proxy is set on your device, access the web-based interface, mitmweb. If you’re connected to the server where this solution is running, you’ll be able to access it through localhost:8081;

  2. If you’ve already made some calls to the server using the application and your device, you’ll be able to see those requests in the proxy UI:

  3. To filter these requests, you’ll have to enter a specific use of the URL pattern in the “Search” box. In our example, our server address is “strigoi\.outsystems\-sandboxes\.net”:

  4. To intercept the requests you’d use the same URL pattern but in the Intercept field:

  5. While intercepting the requests, you may select a particular request and besides inspecting its content, you can also edit the value used by clicking the edit button:

  6. When you’re done with the changes you’ve made to the request, you may resume it using the flow tab at the top:

You can also abort the request (and see how the app would behave) or even replay them (and see how the server would).

When you’re done, don’t forget to remove the proxy configuration from your device.

Happy troubleshooting!

 

PS: As a bonus, you can also use this proxy for troubleshooting your Android device network requests using a similar configuration.



Nice tutorial! Congrats Mauro!! #kudos ;)

Leandro Correa wrote:

Nice tutorial! Congrats Mauro!! #kudos ;)

Thank you Leandro :)


Thank you for detailed post.Help me alot

This is a great tutorial, thank you for sharing!

In newer debug app builds you can use a network inspector feature for iOS. :) With a three-finger-gesture you get a toolbar to open the list of the network requests.


Network inspector toolbar