【问题标题】:problem in connecting to my EC2 instance from android simulator从 android 模拟器连接到我的 EC2 实例时出现问题
【发布时间】:2011-04-02 11:17:42
【问题描述】:

我遇到了一个奇怪的问题,我在 EC2 中部署了一个 Web 服务,它已经启动并且工作正常,但是当我尝试对这些服务执行 REST 请求时,我得到 java.net.SocketException: The operation timed out。当我在笔记本电脑浏览器中尝试相同的 URL 时,它正在工作,但是当我在 Android 模拟器浏览器中尝试时,它给了我错误。

这是我的代码

REST 网址:http://122.248.194.88:8080/data_for?train=12657

代码:-

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://122.248.194.88:8080/data_for?train=12658"); 

        // Execute the request
        HttpResponse response;
        try {
            response = httpclient.execute(httpget);

`

这个 httpclient.execute 正在返回套接字异常,还有什么我需要知道的吗??

虽然我在代理后面,但我在启动模拟器时在模拟器选项中设置了该代理。

【问题讨论】:

  • 不是模拟器,是模拟器

标签: android rest android-emulator amazon-ec2


【解决方案1】:

我在这里使用了示例:http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html 来使用 JSON 字符串。效果很好。

【讨论】:

  • 是的权限已设置我可以从我的浏览器访问谷歌
  • 这对我来说也很好,但是当我尝试我的 URL 时,我在 InputStream source = retrieveStream(url);我不知道有什么问题你能用我的代码试试吗??
猜你喜欢
  • 2020-04-29
  • 2017-03-12
  • 1970-01-01
  • 2020-08-10
  • 1970-01-01
  • 1970-01-01
  • 2022-11-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多