Android WebRTC: use default HTTPS proxy for TCP turn connection

100 views
Skip to first unread message

Matthieu Finiasz

unread,
Nov 15, 2022, 3:25:58 PM11/15/22
to discuss-webrtc
It appears that the Android WebRTC library does not attempt to connect through a proxy, whatever the proxy configuration for the phone/the app.

The default ProxySelector is not called and WebRTC attempts to connect directly.

After searching the web it appears that web browsers are capable of using a proxy for TURN/TCP connections. Is there a way to achieve the same result on Android?

The JNI interface does not seem to expose any possibility to manually configure such a proxy or to provide a turn socket factory... Is there a low level C++ way of forcing the use of a proxy?

Any help on this is welcome!

Matthieu Finiasz

unread,
Nov 19, 2022, 6:43:57 AM11/19/22
to discuss-webrtc
After looking more closely at the source code it seemed rather easy to add support for setting an HTTP proxy when creating the PeerConnectionFactory. I simply created a wrapper around the BasicPacketSocketFactory (which I called ProxyPacketSocketFactory) that simply forces the use of the proxy I pass to my PeerConnectionFactory.Builder when CreateClientTcpSocket is called.

My code definitely does not follow the webrtc coding guidelines, but as it might be useful to others, I put it here. Starting from branch-heads/5304, I attached the `git diff` patch that can be applied.

Maybe a similar (but cleaner) feature could be merged into webRTC? For now I will stick to applying this patch when updating webRTC.
proxy_support.patch
Reply all
Reply to author
Forward
0 new messages