我将使用Twilio AndroidSDK。我需要在socks5代理后面使用Twilio AndroidSDK。
我在twilio-mobile-quickstart中的ClientActivity.java下编写了this代码
新想法:不使用ProxySelector。只有系统属性连接..
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]");
我收到了新的错误。无法连接SSL。 我觉得我的设备直接连接到主机。
Twilio这个https连接无法与代理连接? :(
在封闭网络中,检测此日志:
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)
任何人都可能知道我哪里做错了?提前谢谢。
答案 0 :(得分:1)
Twilio开发者传道者在这里。
我担心Twilio Client Android SDK目前不支持SOCKS代理,这就是您遇到这些问题的原因。
我建议您根据自己的要求与Twilio support联系,如果代理支持已添加到SDK中,他们将能够通知您。
让我知道这是否有帮助。