【问题标题】:Could not connext to Proxy in Android无法连接到 Android 中的代理
【发布时间】:2011-08-05 07:27:06
【问题描述】:

我正在编写一个使用互联网的应用程序。问题是,我有一个代理问题。我已经在网上阅读了一些文章,但没有任何帮助。当我使用
emulator -avd <avd-Name> -http-proxy http:<proxyname>:<proxyip> -debug-proxy

从命令行启动 avd

我收到错误消息:
Could not connect to proxy at http:0: Unkown socket error (Winsock=0xffffffff) errno=2: No such file or directory

感谢您的帮助

【问题讨论】:

    标签: java android proxy


    【解决方案1】:

    您是否使用了正确的语法?

    它应该是以下之一:

    http://<server>:<port>
    http://<username>:<password>@<server>:<port>
    

    http://developer.android.com/guide/developing/tools/emulator.html

    如果这样不行,可以试试(其他)公共代理

    【讨论】:

    • 我确定我尝试了正确的语法...但我的错误是我不必在代理名称前写上proxy 这个词。但我现在的问题是,模拟器识别代理但无法连接到互联网。命令错误总是:tcp:(null)(1516): header sent, receiving first answer line tcp:(null)(1516): received 'HTTP/1.0 400 Bad Request' tcp:(null)(1516): connection refused, error=400 http_service_connect: trying to connect to (null) http_service_connect: using HTTP rewriter tcp:(null)(1500): connecting http_service_free
    • 我解决了通过代理从模拟器连接到互联网的问题 :) :) api 2.1 和 2.2 版本有问题。我只需要创建一个版本为 2.3.3 的新模拟器,它就消失了 :) 在 eclipse 中,我没有只在模拟器网络设置中进行一些设置。但我的应用程序仍然没有互联网连接.. 任何帮助?
    • 您是否将 Internet 权限添加到您的 Manifest 文件? 如果你这样做了,请确保你的模拟器有互联网,使用它的浏览器。
    • 是的,我在清单文件中添加了互联网权限。但是我应该将它添加到应用程序部分吗?或不?我的模拟器可以上网,因为我是用浏览器上网的
    • 是的,我解决了这个问题。问题不是我的。是API版本7。我把API版本改成8,问题就解决了:)
    【解决方案2】:

    当模拟器 -debug-proxy 说:
    tcp:(null)(29): received 'HTTP/1.0 400 Bad Request'
    tcp:(null)(29): connection refused, error=400
    http_service_connect: trying to connect to (null)
    http_service_connect: using HTTP rewriter
    tcp:(null)(30): connecting
    tcp:(null)(30): connected to http proxy, sending header
    tcp:(null)(30): sending 27 bytes:
    43 4f 4e 4e 45 43 54 20 28 6e 75 6c 6c 29 20 48 CONNECT (null) H
    54 54 50 2f 31 2e 31 0d 0a 0d 0a TTP/1.1....

    在 Linux 中,您可以尝试取消设置“http_proxy”环境变量:
    $ unset http_proxy
    然后再次运行模拟器

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 2015-08-20
      • 2017-03-14
      • 2016-05-04
      • 1970-01-01
      • 1970-01-01
      • 2023-02-09
      • 2021-02-12
      • 2018-10-18
      相关资源
      最近更新 更多