/ go Public
x/mobile: network unreachable on Android 10+ via Network request API #52702
Android, iOS, and x/mobile
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
gomobileversion extracted from
Does this issue reproduce with the latest release?
I would say yes, I tried installing
goto that in one terminal instance, but
gomobileis the underlying CLI that builds the aar and that is the latest version.
What operating system and processor architecture are you using (
Not sure if
go envis relevant when talking about Android, but included anyway.
What did you do?
We have a lib written in go that we compile via
gomobileinto an aar and use in our android application. When we connect to a Wi-Fi network via Android's Network request API on Android 10 and up, we cannot initiate a TCP connection from the go code.
According to Android's Wi-Fi infrastructure overview
The problem seems to be that the OS does not recognize the go code as part of the application, but I'm not 100% sure either. We have even tried opening a socket via
syscall.Connect()on that, but it fails with
network unreachablejust the same as it does via
If you connect the phone to the Wi-Fi in question via Settings (i.e. not using the Network request API), then everything works without issue.
The weird thing is that we have another team working with C++ and boost, and they also generate JNI bindings for their native code, but in their case using the Network request API works, so the OS recognizes that code as part of the app and lets it open their sockets. For go, though, it does not, even though the code is running in the same process (
Getpidreturn the same PID both in the go code as well as the native android code).
I have made a minimal reproduction repository where you can observe the behavior: https://github.com/myklosbotond/tcp-unreachable-repro . It only works with android 10 and up and it's important to disable cellular data before the tests. We tested on multiple android versions and on phones from multiple brands, and the bug is present in every case.
What did you expect to see?
Network calls can be done via the Wi-Fi bound to the app.
What did you see instead?
Requests are always failing with
opening a TCP socket fails.
The text was updated successfully, but these errors were encountered: