如何在带有 Java 系统属性的 sock 代理后面使用 Twilio AndroidSDK [英] How to use Twilio AndroidSDK behind sock proxy with Java System Property

查看:24
本文介绍了如何在带有 Java 系统属性的 sock 代理后面使用 Twilio AndroidSDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用 Twilio AndroidSDK.我需要在socks5 代理后面使用Twilio AndroidSDK.

I will use Twilio AndroidSDK. i need using Twilio AndroidSDK behind socks5 proxy.

我在 twilio 的 ClientActivity.java 下写了 this 代码-移动快速入门

I wrote this code under ClientActivity.java in twilio-mobile-quickstart

新想法:不使用 ProxySelector.仅系统属性连接..

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]");

出现新错误.无法连接 SSL.我觉得我的设备直接连接到主机.

I get new errors. can't connecting SSL. i feel my device connect to host directlly.

Twilio 这个 https 连接无法与代理连接?:(

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.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

恐怕 Twilio 客户端 Android SDK 目前不支持 SOCKS 代理,这就是您看到这些问题的原因.

I'm afraid the Twilio Client Android SDK does not currently support SOCKS proxies, which is why you are seeing these issues.

我建议您就您的要求与 Twilio 支持联系,他们将能够通知您是否向 SDK 添加了代理支持.

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.

这篇关于如何在带有 Java 系统属性的 sock 代理后面使用 Twilio AndroidSDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆