Charles Web Debugging Proxy
- Install and Register Charles Proxy
- Setup Proxy
- Connect Your Devices
- Install SSL Certification on Your Devices
- Test and View MoPub Ad Requests/Responses
- Save and Send Session Logs
- FAQ
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
- Download Charles Proxy here.
- On the Charles menu bar, go to Help > Register Charles…. You can also use a trial version with some limitations.
Setup Proxy
-
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.
-
Enable Proxy ( Proxy > Proxy Settings… > Proxies )
-
Enable SSL Proxying ( SSL Proxy Settings… )
Add a wildcard host to enable all SSL:
Or explicitly add MoPub host to the list:
Host: *.mopub.com Port: *
-
Add MoPub host to Focussed Hosts ( View > Focussed Hosts… > Add )
Connect Your Devices
Android
-
Go to Settings > WiFi and connect to the network your computer is connected to
-
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
- Go to Settings > WiFi and connect to the network your computer is connected to
-
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
-
Go to Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device…
-
On your Android or iOS device, follow the instruction to browse to http://chls.pro/ssl to download and install the certificate.
-
Navigate to Settings > General > Profile & Device Management to install and verify the Charles SSL certificate.
-
Navigate to Settings > General > About > Certificate Trust Settings to mark the Charles Root certificate as trusted.
Important
On Android 7+ :
If Charles is 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
-
Launch MoPub Sample App or your own apps that has integrated MoPub SDK.
-
Go to Charles Files > New Session to start a new recording if need be.
-
Click on the besom icon to clear the logs, and make sure to enable the recording.
![Clear and Record][9]
-
Trigger ad requests and reproduce any issues you’ve encountered.
-
You should start seeing the ad requests and responses decrypted as below:
-
Click Focused or type ‘mopub’ into the Filter to filter out the traffic that are sent through the MoPub server.
![Filter][8]
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 app opened tracker:
- http://ads.mopub.com/m/open
- MoPub ad request:
-
Disable the recording.
Save and Send Session Logs
- Ensure your session logs are decrypted.
- Recorded sessions can be saved as
.chls
files, or exported as HTTP Archive (HAR) logs from File > Export Session… - Send the files to your account manager.
FAQ
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.
Why is my https logs are encrypted?
- Ensure your SSL Proxying is enabled and already allowlisting 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.
s/ [8]: /assets/images/tools/Charles-050.png [9]: /assets/images/tools/Charles-060.png
Last updated December 03, 2020
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.
© 2020 MoPub (a division of Twitter, Inc.)