Charles Web Debugging Proxy

Charles Proxy is a HTTP/HTTPS traffic viewer by which you can view the traffic between your device and the internet. Since the MoPub SDK uses HTTP/HTTPS to request and receive ads, Charles can be used to see what is happening for debugging and testing apps ad request/response.

Install and Register Charles Proxy

  1. Download Charles Proxy here.
  2. On the Charles menu bar, go to Help > Register Charles…. You can also use a trial version with some limitations.

Setup Proxy

  1. Open Charles

    The first time you launch Charles, you will be asked to grant privileges to change your Network Settings. Click “Grant Privileges” and enter your password when prompted.

  2. Enable Proxy ( Proxy > Proxy Settings… > Proxies )

    Enable Proxy Screenshot

  3. Enable SSL Proxying ( SSL Proxy Settings… )

    Add a wildcard host to enable all SSL:

    Enable SSL Proxying Screenshot

    Or explicitly add MoPub host to the list:

     Host: *.mopub.com
     Port: *
    
  4. Add MoPub host to Focussed Hosts ( View > Focussed Hosts… > Add )

    Add Focussed Hosts Screenshot

Connect Your Devices

Android

  1. Go to Settings > WiFi and connect to the network your computer is connected to

  2. Long press the network until the modal appears, then click Modify Network. Select Advanced Options to reveal proxying options. Configure the following:

     Proxy: Manual
     Proxy hostname: [Your computer's IP Address]
     Port: 8888
    

iOS

  1. Go to Settings > WiFi and connect to the network your computer is connected to
  2. Select “i” next to the network, and scroll down to HTTP Proxy and select Manual. Configure the following:

     Server: [Your computer's IP Address]
     Port: 8888
    

You should see a prompt when your device successfully connect to your computer, press Allow to complete the connection.

Install SSL Certification on Your Devices

  1. Go to Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device…

  2. On your Android or iOS device, follow the instruction to browse to http://chls.pro/ssl to download and install the certificate.

Important

On Android 7+ :

If Charles does not able to decrypt https traffic, please follow this insturction to add a network_security_config.xml and modify your AndroidManifest.xml in your app.

res/xml/network_security_config.xml
<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system"/>
        </trust-anchors>
    </base-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="user"/>
        </trust-anchors>
    </debug-overrides>
</network-security-config>
AndroidManifest.xml
<application
...
android:networkSecurityConfig="@xml/network_security_config">

Note: please remember to revert this before your app goes live.

On iOS 10.3+ :

You have to go to Settings > General > About > Certificate Trust Settings to toggle the full trust of the certificate.

Test and View MoPub Ad Requests/Responses

  1. Launch MoPub Sample App or your own apps that has integrated MoPub SDK.

  2. Go to Charles Files > New Session to start a new recording if need be.

  3. Click on the besom icon to clear the logs, and make sure to enable the recording.

    Clear and Record

  4. Trigger ad requests and reproduce any issues you’ve encountered.

  5. You should start seeing the ad requests and responses decrypted as below:

    Ad requests and Responses Screenshot

  6. Click Focused or type ‘mopub’ into the Filter to filter out the traffic that are sent through the MoPub server.

    Filter

    Below will be exposed in the Charles log if ad requests to MoPub were captured:

    • MoPub ad request:
      • http://ads.mopub.com/m/ad
    • MoPub attempt tracker:
      • http://ads.mopub.com/m/attempt
    • MoPub impression tracker:
      • http://ads.mopub.com/m/imp
      • http://mpx.mopub.com/imp (for Marketplace only)
    • MoPub click tracker:
      • http://ads.mopub.com/m/aclk
      • http://mpx.mopub.com/aclk (for Marketplace only)
    • MoPub conversion tracker:
      • http://ads.mopub.com/m/open
  7. Disable the recording.

Save and Send Session Logs

  1. Ensure your session logs are decrypted.
  2. Recorded sessions can be saved as .chls files, or exported as HTTP Archive (HAR) logs from File > Export Session…
  3. Send the files to your account manager.

FAQ

Q: Why can’t I see any traffic recorded in Charles?

  • Ensure your Charles Recording toggle is on.
  • Confirm if your mobile and your computer are connecting to the same WiFi.
  • Confirm if the proxy IP is identical with your computer’s IP.
  • Restart your Charles tool on your computer, and reconnect your devices to the WiFi.
  • Disable any VPN on your mobile.

Q: Why is my https logs are encrypted?

  • Ensure your SSL Proxying is enabled and already whitelist correct host name.
  • Redo the steps in the secton: “Install SSL Certification on Your Devices”.
  • Restart your Charles tool on your computer, and reconnect your devices to the WiFi.

Last updated October 10, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.