Answer
To debug mobile applications using whistle, you need to configure the mobile device's network proxy to access the network through the whistle proxy server.
Basic Configuration Steps
1. Ensure Device and Computer Are on Same Network
- Connect phone and computer to the same Wi-Fi network
- Or use USB shared network
2. Get Computer IP Address
Windows:
bashipconfig
Mac/Linux:
bashifconfig
Record the computer's IP address, for example: 192.168.1.100
3. Start Whistle
bashw2 start
Confirm whistle is running, default port is 8899
4. Configure Phone Proxy
iOS Device:
- Open "Settings" → "Wi-Fi"
- Click the "i" icon next to the connected Wi-Fi
- Scroll to bottom, find "HTTP Proxy"
- Select "Manual"
- Server: Enter computer IP address
- Port: Enter
8899
Android Device:
- Open "Settings" → "Wi-Fi"
- Long press the connected Wi-Fi
- Select "Modify network" or "Network details"
- Show advanced options
- Proxy: Select "Manual"
- Proxy hostname: Enter computer IP address
- Proxy port: Enter
8899
HTTPS Certificate Configuration
1. Access Whistle from Phone Browser
Visit in phone browser: http://computerIP:8899/
For example: http://192.168.1.100:8899/
2. Download and Install Certificate
- Click "HTTPS" tab
- Click "Download RootCA" to download certificate
- Install certificate after download
iOS Certificate Installation:
- After download, open "Settings" → "Downloaded Profile"
- Click to install certificate
- After installation, go to "Settings" → "General" → "About" → "Certificate Trust Settings"
- Find whistle certificate, enable "Full Trust for Root Certificates"
Android Certificate Installation:
- Open certificate file after download
- Follow prompts to install certificate
- After installation, go to "Settings" → "Security" → "Encryption & credentials" → "Trusted credentials"
- Confirm certificate is installed
Verify Configuration
1. Test HTTP Request
Visit any website in phone browser, check if whistle management interface shows request records.
2. Test HTTPS Request
Visit HTTPS website, confirm it loads normally and whistle can intercept requests.
Common Issues and Solutions
1. Cannot Connect to Proxy
Check items:
- Confirm computer and phone are on same network
- Check if computer firewall blocks port 8899
- Confirm whistle is running
- Try pinging computer IP address
2. HTTPS Request Fails
Solutions:
- Confirm certificate is correctly installed and trusted
- Restart phone browser
- Clear browser cache
- Check if whistle HTTPS interception is enabled
3. Some Apps Cannot Be Intercepted
Reasons:
- App uses certificate pinning
- App uses custom network library
- App detects proxy environment
Solutions:
- Use debugging tools that support certificate pinning
- Perform reverse engineering on the app
- Use virtual machine or emulator for debugging
Advanced Tips
1. Use USB Debugging
For Android devices, use ADB to forward ports:
bashadb reverse tcp:8899 tcp:8899
2. Configure Rules
Add mobile-specific rules in whistle:
shell# Mobile-specific rules m.example.com resBody://{mobile-mock.json} app.example.com reqHeaders://{mobile-headers.json}
3. Capture App Network Requests
- Ensure app uses system network library
- Disable app's network detection
- Use Wi-Fi instead of mobile data
Security Considerations
-
Do Not Use on Public Networks
- Avoid configuring proxy in public places like cafes
- Prevent sensitive information from being stolen
-
Close Proxy After Debugging
- Close phone proxy settings in time
- Stop whistle service
-
Protect Certificate Security
- Do not share certificate with others
- Regularly replace certificate