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

UdsChannelBuilder does not work with WiFi Proxy on Android #11922

Open
Rawa opened this issue Feb 24, 2025 · 2 comments
Open

UdsChannelBuilder does not work with WiFi Proxy on Android #11922

Rawa opened this issue Feb 24, 2025 · 2 comments
Milestone

Comments

@Rawa
Copy link

Rawa commented Feb 24, 2025

UdsChannelBuilder does not work with WiFi Proxy on Android.

What version of gRPC-Java are you using?

1.70.0

What is your environment?

Android

What did you expect to see?

gRPC connection to work

What did you see instead?

TRANSIENT_FAILURE

[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}
[{0}] Failed to resolve name. status={1}

Steps to reproduce the bug

Setup UdsChannelBuilder and connect to a server.
Connect to a WiFi on Android
On the WiFi you are connected press the pen symbol to add a proxy
Add a dummy proxy

The UdsChannelBuilder will be unable to connect and ends up in TRANSIENT_FAILURE state.


I've managed to find a workaround by setting proxyDetector to be null:

    private val channel =
        UdsChannelBuilder.forPath(
                rpcSocketFile.absolutePath,
                LocalSocketAddress.Namespace.FILESYSTEM,
            )
            .proxyDetector { null }
            .build()

Adding a log to the proxy detector I can see that a lookup happens:

Proxy detector invoked for: 127.0.0.1/<unresolved>:80

I believe the bug goes as follows:

Under the hood the UdsChannelBuilder uses a ManagedChannelImpl, however it with a bit of a hack uses 127.0.0.1, see here

.invoke(null, "dns:///127.0.0.1", InsecureChannelCredentials.create());

By default if no ProxyDetector is set but if none is set a default is applied in ManagedChannelImpl here

builder.proxyDetector != null ? builder.proxyDetector : GrpcUtil.DEFAULT_PROXY_DETECTOR;

So default proxy detector will then yield an error when trying to lookup 127.0.0.1, maybe because internet didn't work through the proxy? My guess is that this is then emitted as an error and thus it enters here

logger.log(Level.WARNING, "[{0}] Failed to resolve name. status={1}",
where it logs the error and also puts the channel in TransientFailure.

@Rawa
Copy link
Author

Rawa commented Feb 24, 2025

I'm not sure about the best way to address this, it is a bit weird that the entire stack depends on IP, especially for UDS. So that is a bit hard to change, I guess one could provide an empty proxyDetector by default like I did in my workaround above.

@kannanjgithub
Copy link
Contributor

kannanjgithub commented Feb 25, 2025

A UDS name resolver wouldn't check the proxySelector, so disabling the proxy selector (setting a noop) sounds fine.
It is annoying we don't know what error actually happened, though.

" I guess one could provide an empty proxyDetector by default like I did in my workaround above"

Contribution is welcome if you are so inclined.

@kannanjgithub kannanjgithub added this to the Next milestone Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants