mirror of
https://github.com/ProxymanApp/Proxyman.git
synced 2026-04-26 16:45:57 +03:00
[GH-ISSUE #1407] Debugging React Native on Android breaks when using Proxyman #1402
Labels
No labels
Discussion
Feature request
In Progress...
Plugins
Waiting response
Windows
Windows
bug
duplicate
enhancement
feature
good first issue
iOS
macOS 10.11
question
wontfix
✅ Done
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Proxyman#1402
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Justin-Credible on GitHub (Oct 20, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1407
Originally assigned to: @NghiaTranUIT on GitHub.
Description
When using Proxyman as a proxy for an Android device's traffic while running a React Native application in development mode, if React Native debugging is disabled, the app does not work. React will stop with the fatal error
Failed to connect to debugger! Timeout while connecting to remote debugger.When this occurs you can see the websocket traffic in Proxyman: localhost_10-20-2022-15-28-04.proxymanlog.zip
It appears that Proxyman is intercepting the websocket requests which I believe React Native uses for debugging. Something isn't quite working correctly though.
Steps to Reproduce
npx react-native startadb reverse tcp:8081 tcp:8081adb shell input keyevent 82Current Behavior
Application restarts in debugging mode, but immediately fails with:
Failed to connect to debugger! Timeout while connecting to remote debugger.Expected Behavior
Application restarts in debugging mode and works without any errors.
Environment
Additional notes
This does not affect iOS when using either the iOS simulator or a physical iOS device. In this case I've noticed that websocket traffic does not show up at all in Proxyman; perhaps this is why iOS doesn't have the same issue?
@NghiaTranUIT commented on GitHub (Oct 21, 2022):
Thanks for the detailed report @Justin-Credible
You're right. Websocket on iOS doesn't respect the HTTP Proxy, so it won't go through Proxyman app.
On the other hand, Android does. Maybe it's the reason why your Android app (React Native) doesn't work. I'm going to investigate it now.
Maybe I should bypass all React Native debugging Websocket instead of intercepting it.
@NghiaTranUIT commented on GitHub (Oct 25, 2022):
Hey @Justin-Credible I've spent hours investigating, but the
npx react-native run-androidis extremely unreliable 😢I've followed the official guideline from React Native at https://reactnative.dev/docs/environment-setup
Without opening Proxyman, 9 out of 10, the command just returns an error. I have to remove the emulator and create a new one, it runs successfully Once, then breaks again.
Thus, I could not reliably reproduce the bug. I suppose that it's about the WS via Proxyman when you use
adb reverse tcp:8081 tcp:8081.If you don't mind, please try to remove all reverse, e.g
adb reverse --remove-all, and try again, it might fix the problem.@Justin-Credible commented on GitHub (Oct 25, 2022):
Running
adb reverse tcp:8081 tcp:8081is required during development in most cases, as this is how React Native normally loads the application bundle. I tried it without usingadb reverseby and setting the bundle location via React Native's debug menu to a local network IP/port (e.g.192.168.1.20:8081), but as soon as ProxyMan was enabled as the proxy, React Native debugging broke. (as a side note I noticed that Charles Proxy does not exhibit this problem)To work around the issue I made a Proxy auto-config script to tell Android to bypass the proxy for
localhostonly, while proxying all other hosts. This allowed me to work around the ProxyMan/websocket issue.@NghiaTranUIT commented on GitHub (Oct 26, 2022):
Thanks for the update. I will try again to reproduce and fix it this weekend 👍
@yoniholmes commented on GitHub (Mar 7, 2023):
Hi @Justin-Credible, thanks very much for raising this ticket and sharing your work around. Would you be able to elaborate on your Proxy auto-config solution? Where do you place this code / how is it run?
I'm facing a similar issue. My React Native app is successfully proxying all network traffic to Proxyman only what I believe are the metro bundler calls, /inspector, /message, /status are all resulting in Internal Error 999 and therefore the app returns an error saying that it cannot connect to the development server. ’adb reverse tcp:/8081 tcp:8081’ is not helping - hence would like to try to prevent these calls from proxying through Proxyman.
Many thanks to anyone in advance with any thoughts!
@Justin-Credible commented on GitHub (Mar 17, 2023):
@yoniholmes
Sure, it looks like this:
proxy.pacfile with the contents of the above post192.168.1.60:9090part of the script to be the IP/port of your Proxyman instanceproxy.pacon a webserver and ensure it is served with aContent-Type: application/x-ns-proxy-autoconfigresponse headerProxy Auto-Configproxy.pacfile and save the changesFrom now on, the contents of the
proxy.pacscript will execute for each URL to determine if it should be passed through the proxy or not. The simple script above will ignore any requests tolocalhostwhich should be the metro bundler. Everything else will be proxied.Hope this helps!
@yoniholmes commented on GitHub (Mar 17, 2023):
Thanks! I’ll give it a try. I managed to point my wifi config to a server
hosting the pac file but I didn’t serve it with the Content-Type:
application/x-ns-proxy-autoconfig header. Thanks for coming back to me! 🤞
On Fri, 17 Mar 2023 at 21:17, Justin Unterreiner @.***>
wrote:
@yoniholmes commented on GitHub (Apr 3, 2023):
I managed to get this working. Steps:
proxy.pac, returning with aContent-Type: application/x-ns-proxy-autoconfigheader, as per the contents shared above, i.e.:http://[my IP Address]:8080), note I don't specify proxy.pac in the URLAfter this point all traffic from my Android was passing through Proxyman, and there were no issues with the Metro bundler failing to connect.
@yoniholmes commented on GitHub (Apr 5, 2023):
So, while this worked for about a day - and what a glorious day it was - the setup later stopped working. I use a VPN so my IP address changed. But no amount of updating IP addresses have fixed the issue, so I can no longer inspect network traffic with Proxyman with my Android Emulator. I've spent at least a day trying to get it to work - but the Emulator consistently fails to attach to the metro bundler, both with and without the
proxy.pacfile in use.Would be great if someone could share and insight or success with using Proxyman with Android. Many thanks in advance.
@NghiaTranUIT commented on GitHub (Apr 5, 2023):
@yoniholmes do you have any current solution with other tools like Charles Proxy + React Native? Maybe I should look into it and make it easier 🤔
@yoniholmes commented on GitHub (Apr 5, 2023):
Hi @NghiaTranUIT, thanks. I haven't tried Charles Proxy.
With React Native Debugger I can see most network calls. However, I cannot see network calls from web views (I can with Proxyman on iOS, and once on Android). Also, React Native Debugger doesn't let me modify requests or responses. I really like Scripting with Proxyman, and would love to use it to debug the Android specific bug I'm facing.
Only, as mentioned, I cannot get this to work. To be clear, Android can successfully pass traffic to Proxyman, which I can inspect. But the React Native app fails to connect to the metro bundler, which is a fatal error meaning I cannot test my app.
@NghiaTranUIT commented on GitHub (Apr 5, 2023):
To intercept traffic from the Webview inside the Android app, you should check this doc: https://docs.proxyman.io/debug-devices/android-device#intercept-traffic-from-embedding-webview
Do you any sample React Native App that I can reproduce it?
@yoniholmes can I use https://reactnative.dev/ to create an app for testing?
@yoniholmes commented on GitHub (Apr 5, 2023):
Re: Webview inpsection
Actually this was working fine, I didn't need to make any further configuration changes
Re: Sample React Native App
Yes that site should get you set up quite quickly. I don't have a sample app for you at the moment, and may not be able to set one up immediately.
@yoniholmes commented on GitHub (Apr 5, 2023):
These are the errors I get. With Proxyman off, Android works fine.
@NghiaTranUIT commented on GitHub (Apr 5, 2023):
@yoniholmes Can you try to add this IP to the Bypass list in the Wifi?
You can find it at System Setting -> Wifi -> Details -> Proxy -> Bypass Proxy Setting
@yoniholmes commented on GitHub (Apr 5, 2023):
Sure I'll try that and let you know.
@NghiaTranUIT commented on GitHub (Apr 5, 2023):
Just wondering what Proxyman for macOS version you're using?
I've tried on the latest build, and it seems the Metro is still working fine 🤔 I can update the App.js and hot-reload is still working.
Bridge was already shutdown.@yoniholmes commented on GitHub (Apr 5, 2023):
Thanks for sharing. I'm using Proxyman 4.5.0 (45000).
Still failing for me after putting 10.0.2.2 into my wifi proxy bypass settings.
I'm not sure whether Expo might play any role – that port 19000 looks to be related to Expo, which is used in the React Native quick start. My project doesn't use Expo, so am not sure whether that's a factor.
I've tried both with and without VPN. Traffic from Android is all proxying to Proxyman, but the metro bundler 10.0.2.2:8081 calls all fail with code 999, Status 'Internal Error'
The message in the 'Response' panel in Proxyman says:
@NghiaTranUIT commented on GitHub (Apr 5, 2023):
@yoniholmes I found a solution for React Native via Metro Bundler 👍
Android Emulator
localhostin the bypass Proxy List ✅The Bridge Was shutdownwarning is gone ✅Android Device
your IPin the bypass Proxy List ✅ . In your case, it's10.0.2.2@yoniholmes commented on GitHub (Apr 5, 2023):
Hi @NghiaTranUIT, yes! Thank you very much, I now have Android working with Proxyman. Truly appreciated, was stuck on this for a long time!
After making the manual WiFI proxy changes within Android (I'd switched off mobile data previously, so the only network I was using as the Emulator's WiFi network), along with the bypass settings (I added "localhost,10.0.2.2" to be sure, but I can test the difference later), then I could run my app, no metro bundler connectivity issues, and I could inspect network traffic from my app. 🎉
Without adding the
res/xml/network_security_config.xml, the metro bundler would still connect, and I could see the domains that my app was calling, but I could not inspect them. After restoring thenetwork_security_config.xmlfile, I could then run my Android app, no metro bundler issues, and I could inspect the calls being made from the app.Thanks again & hope you enjoy the rest of your week!
@NghiaTranUIT commented on GitHub (Apr 6, 2023):
Awesome, I will add my instruction to the React Native document page.
@coofzilla commented on GitHub (Feb 15, 2024):
I was having a similar issue. Does the automated setup work with
react-native? Basically pressing thisoverride emulatoror do you have to manually add it in the actual settings of the emulator?Also, do you have to add it to both settings?
Referencing this automated setup.

Current setup:
but then I get the same like above:
I tried those steps; but, still facing the same issue :/
Got it fixed
Can someone enlighten me as to why that is needed ? 🤔
@NghiaTranUIT commented on GitHub (Feb 15, 2024):
@coofzilla:
Yes, it's.
You only either use the Emulator or manual setting for Android devices. Don't need to use twice.
If you mean the step 3 that you modify the
network.xml, it's required.@coofzilla commented on GitHub (Feb 15, 2024):
@NghiaTranUIT Thank you for the response, the only issue I have now is, when I quit proxyman. I have to undo everything to get it to work normally again. Conversely, setting up, I have to redo everything I just undid such as setting up all the local host stuff. Is that intended?
@NghiaTranUIT commented on GitHub (Feb 15, 2024):
Yes, you have to revert all proxy settings if you don't use Proxyman on your emulator.
Please click on the Revert Button at the end 👍
Proxyman uses the
adbcommand line to modify your Android emulator.@MariuzM commented on GitHub (Jul 16, 2024):
I don’t know on Android with RN+Expo nothing works for me :(

And tried again

Tried new emulator and just follow the steps for RN but nothing works
@wijskinner commented on GitHub (Aug 29, 2024):
Really struggling here as well. Network traffic all going through but metro telling me to do one.
@NghiaTranUIT commented on GitHub (Aug 30, 2024):
@wijskinner if you don't mind, can you share with me a sample Metro React Native project that I can reproduce?
Maybe the Getting Started project from Metro will work?
@NghiaTranUIT commented on GitHub (Aug 30, 2024):
@wijskinner from what I know, React Native (Expo) is working fine with Proxyman, and Metro is deprecated, right?
On the React Native website, I don't see any Setup for Metro anymore.
@wijskinner commented on GitHub (Aug 30, 2024):
@NghiaTranUIT Thanks for response. They have fairly recently switched to recommending expo as the default setup. Metro is just the bundler that react-native and expo uses under the hood to enable live bundling/reloading of the underlying javascript. There are a LOT of non expo react-native projects out there as back in the day there were a lot of restrictions on what you could do with a non ejected expo project. It is virtually impossible to switch to expo on a large codebase that didn't start with it.
With regards to metro - there isn't a setup as such. It is included with a normal react native setup. I'm guessing the difference between expo bundler and vanilla metro will be to do with how it handles ports and reverse proxying etc on android.
Setup for RN app without expo is still in the docs https://reactnative.dev/docs/getting-started-without-a-framework
@wijskinner commented on GitHub (Sep 6, 2024):
@NghiaTranUIT any update on this?
@NghiaTranUIT commented on GitHub (Sep 15, 2024):
@wijskinner not yet, let me investigate the RN Metro with Proxyman and get back to you 👍
@NghiaTranUIT commented on GitHub (Sep 15, 2024):
@wijskinner @Justin-Credible good news: Here is the solution 🎉
Please note that this issue is not Proxyman's bug. It also happens on Charles Proxy.
React Native - Metro - iOS app
React Native - Metro - Android Emulator
Override Emulator-> It auto set the Proxy and install the certificate in 1 clickIf you'd like to decrypt HTTPS on your Android Emulator, make sure to add the
network.xmlconfig to your Android project.@NghiaTranUIT commented on GitHub (Sep 15, 2024):
I will add some logic to automatically fix this issue in build v5.9.0, so it can work out of the box. No need to use Map Remote 👍
@NghiaTranUIT commented on GitHub (Sep 15, 2024):
cc @wijskinner @Justin-Credible @MariuzM @coofzilla @yoniholmes
If you don't mind, let's try this Beta build: https://download.proxyman.io/beta/Proxyman_5.8.0_Fix_React_native_with_metro_bundler_for_android.dmg
Changelog
yarn androidand it worksVideo
https://github.com/user-attachments/assets/de9d93b1-a13a-4dab-a44a-c273a3d468fc
@wijskinner commented on GitHub (Sep 27, 2024):
Sorry just caught up here. Will try that build and report back. Thanks a bunch for looking at this.
@wijskinner commented on GitHub (Sep 27, 2024):
Working fine over here. Thanks again. 👍