问题
I will use Twilio AndroidSDK. i need using Twilio AndroidSDK behind socks5 proxy.
I wrote this code under ClientActivity.java in twilio-mobile-quickstart
NEW IDEA: no use ProxySelector. only Systems Property Connecting..
protected void onCreate(Bundle savedInstanceState) {
System.setProperty("java.net.useSystemProxies","true");
System.setProperty("proxyHost","[Proxy Server Addr]");
System.setProperty("proxyPort","[Proxy Server Port]");
System.setProperty("http.proxyHost","[Proxy Server Addr]");
System.setProperty("http.proxyPort","[Proxy Server Port]");
System.setProperty("https.proxyHost","[Proxy Server Addr]");
System.setProperty("https.proxyPort","[Proxy Server Port]");
System.setProperty("socketsProxyHost","[SOCKS5 Server Addr]");
System.setProperty("socketsProxyPort","[SOCKS5 Server Port]");
I get new errors. can't connecting SSL. i feel my device connect to host directlly.
Twilio this https connection can't connect with proxies? :(
in closed network, detect this log:
01-31 16:17:15.617 17711-30305/com.twilio.client.quickstart D/HttpLongPollThread: connecting to host matrix.twilio.com on port 443
01-31 16:17:15.697 17711-30305/com.twilio.client.quickstart W/HttpLongPollThread: long poller got exception
java.net.ConnectException: failed to connect to matrix.twilio.com/52.54.166.186 (port 443) after 30000ms: isConnected failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.isConnected(IoBridge.java:234)
at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.twilio.client.impl.net.HttpLongPollThread.setUpSocket(HttpLongPollThread.java:62)
at com.twilio.client.impl.net.HttpLongPollThread.run(HttpLongPollThread.java:287)
Caused by: android.system.ErrnoException: isConnected failed: ENETUNREACH (Network is unreachable)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
at java.net.Socket.connect(Socket.java:884)
at com.twilio.client.impl.net.HttpLongPollThread.setUpSocket(HttpLongPollThread.java:62)
at com.twilio.client.impl.net.HttpLongPollThread.run(HttpLongPollThread.java:287)
Anyone might have an idea where did i do wrong? Thanks in advance.
回答1:
Twilio developer evangelist here.
I'm afraid the Twilio Client Android SDK does not currently support SOCKS proxies, which is why you are seeing these issues.
I recommend you get in touch with Twilio support with your requirements and they will be able to notify you if proxy support is added to the SDK.
Let me know if that helps at all.
来源:https://stackoverflow.com/questions/41951879/how-to-use-twilio-androidsdk-behind-sock-proxy-with-java-system-property