A bit over my head here. I'm using charles and it ...
# squarelibraries
c
A bit over my head here. I'm using charles and it works fine inspecting all of my retrofit calls. But when I use mockHttpServer from okhttp and I'm hooked up to charles I get a failure.
Copy code
<h1>Charles Error Report</h1>
<h2>Failed to connect to remote host</h2>
Is there some kind of configuration I can set on mockHttpServer so I can have it set to localhost but also use charles?
e
"localhost" to Charles is not the same host as "localhost" on device
if you run the mock server directly on the computer running Charles instead it might work
c
That might be true, but I'm constrained to running the mockHttpServer on the device and so I want to see that traffic in charles even though it's mocked. I can see the requests come into charles, but the response is always the error snippet in the OP
e
that's entirely expected, when you're using the proxy it's Charles attempting to connect to "localhost", which from its perspective doesn't respond
you may be able to hack something together with
adb forward tcp:8080 tcp:8080
(or whatever your port is)
c
will look into those commands. my main problem is that my testers have these builds available to them where I run a mockwebserver (because our backend isn't ready) and they are used to using charles proxy and so an adb command isn't really a solution that'd work for my situation.
Hm. I wonder if this gets me any closer. https://www.charlesproxy.com/documentation/faqs/localhost-traffic-doesnt-appear-in-charles/ But I guess in this case... localhost traffic is showing up, it's just that it's androids localhost, and not the machine I'm running on.
e
if you're using Charles, it has to be able to forward (proxy) connections to the server, period. if you can't reliably use ADB there's probably no other reliable methods either
there's other tools like https://github.com/ChuckerTeam/chucker and https://fbflipper.com/docs/getting-started/android-native/ that hook in at the network layer of the application itself instead of going through an external proxy
c
Gotcha. Looks like I won't see my image library load requests if I go through chucker (I have it setup now). Looks like I have some decisions to make. Appreciate the tips
Just following up on this. When you setup a proxy on your device, you can omit certain domains in the wifi settings. So on your phone you can just do that and I can have my localhost connections work properly, while being able to inspect other traffic (like images). 👍
e
ah, it wasn't clear that you didn't want to inspect localhost traffic but had other traffic instead
c
I mean. Ideally I'd be able to see both, but yeah the localhost traffic I can modify, but the other calls I can't.
109 Views