Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch hangs on some devices if IPv6 is not available #6954

Closed
andreialecu opened this issue Dec 9, 2021 · 8 comments
Closed

fetch hangs on some devices if IPv6 is not available #6954

andreialecu opened this issue Dec 9, 2021 · 8 comments
Labels
bug Bug in existing code

Comments

@andreialecu
Copy link

I'm crossposting this based on an issue in React Native that seems to be fixed by prioritizing IPv4 IP addresses in DNS requests over IPv6 ones.

There's more context here: facebook/react-native#32730

I have a device where the lack of IPv6 would hang any network requests to domains that advertise IPv6 addresses. This device is an Oppo A72 if it's relevant.

Android connectivity issues have been frequently reported in React Native. So much so that there is a workaround posted here: https://gist.github.com/danmaas/c60af5fed9f55d2bc616ce302696540d which did indeed fix the problem I was seeing.

However, after further troubleshooting I noticed that the device itself did not have IPv6 connectivity or an IPv6 address at all. I'm not sure why okhttp would even attempt to use IPv6.

Eventually I went into the router's admin panel and reconnected IPv6, which resulted in the connectivity being brought back online. This instantly fixed the faulty device.

I have two Android devices to test with, one did not exhibit the problem while the second one did. It could be an implementation detail or a bug in the device, however, other apps did not seem to have issues.

Is there anything okhttp could do about this? Please see facebook/react-native#32730 for a full description of the issue.

@andreialecu andreialecu added the bug Bug in existing code label Dec 9, 2021
@yschimke
Copy link
Collaborator

yschimke commented Dec 9, 2021

The ideal fix would be happy eyeballs, but we don't have that. That would try both routes and use the first one to return (or similar).

The correct behaviour of OkHttp should be that it denylists those broken routes when they occur so that future requests only happen on the IPv4 routes that work. Hopefully the requests recover after initial failures and timeouts. If not, then it's a bug we should look into.

I'd suggest using the EventLogger to see exactly what is going on with calls, dns, connections and so on.

  OkHttpClient client = new OkHttpClient.Builder()
    .eventListenerFactory(new LoggingEventListener.Factory())
    .build();

Can you provide that output?

We attempt to use IPv6 because the system DNS is returning it. Can you confirm you think the system is returning both IPv4 and IPv6 for DNS lookups? And that you are using the same client instance for requests?

There isn't much we can do without hooking in tightly with to either this situation, sorting IPv4 first, or hooking into Android network and trying to determine the network state. But all of that shouldn't be baked into OkHttp, we provide the set of extension poijts to allow you to do this as a final workaround if needed.

@leah9227-arkus
Copy link

Guys, I need to ask you if are you having some trouble with this library:
http://tokbox.bintray.com/maven/com/squareup/okhttp3/okhttp-bom/4.4.1/okhttp-bom-4.4.1.pom

I'm currently having troubles with that and I just can't build APK from a react-native project because returns me a 502 Bad Gateway error. Sorry if this questions does no belong to this topic.

@andreialecu
Copy link
Author

andreialecu commented Dec 9, 2021

We attempt to use IPv6 because the system DNS is returning it. Can you confirm you think the system is returning both IPv4 and IPv6 for DNS lookups? And that you are using the same client instance for requests?

Thank you for the answer @yschimke

Considering the workaround in https://gist.github.com/danmaas/c60af5fed9f55d2bc616ce302696540d initially fixed the error, I think that confirms that IPv6 addresses were being returned.

The problem seems to have been some sort of WiFi Router glitch. It was not showing any IPv6 address but it was reporting it was connected. The router is a TP-Link AX1500 Wi-Fi 6 Router for context.

What I saw in its dashboard was IPv6 Address: :: but it was reporting a status of Connected.

If I try to disconnect the IPv6 address altogether from the Router, then I'm not able to reproduce the problem on this particular device.

What I did notice was that https://ipv6-test.com/ reported that websites that are IPv6 only would time out and be unreachable.

So until the router starts glitching again I'm not sure how to reproduce this. The problem seems to be that the initial failure and timeout was taking way too long.

I'm not sure if this is a React Native issue with how it uses OKHttp however.

@andreialecu
Copy link
Author

If more data points help in prioritizing this (or happy eyeballs), I think this entire thread is caused by this behavior in okhttp:

aws-amplify/amplify-js#5539

@andreialecu
Copy link
Author

andreialecu commented Dec 10, 2021

This is what the ip6-test website was reporting by the way:

Screenshot 2021-12-10 at 13 52 33

Also this:
Screenshot 2021-12-10 at 14 05 38

@yschimke
Copy link
Collaborator

Just flagging this just landed #506 - so you could test with a local build, or wait for the next alpha #506

@swankjesse
Copy link
Member

No further action to take on this.

@Espionage724
Copy link

The problem seems to have been some sort of WiFi Router glitch. It was not showing any IPv6 address but it was reporting it was connected. The router is a TP-Link AX1500 Wi-Fi 6 Router for context.

I have a TP-Link AX1500 router and when using it by itself in router mode, my Android phone (OnePlus 6, Android 11-14, T-Mobile MVNO) couldn't use VoWiFi. Even with all router firewalls and any obvious shaping/QoS disabled. I was also failing ICMPv6 or something with IPv6 tests even with an address.

I put the AX1500 in AP/dumb mode for just wifi, connected to another router running OpenWRT for DHCP/stuff, and everything works fine (VoWiFi on Android, all IPv6 tests). I suspect the AX1500 firmware does something with traffic/packets further than what the GUI allows configuring, or has improper config for IPv6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code
Projects
None yet
Development

No branches or pull requests

5 participants