使用真实设备在本地服务器上测试App Engine Connected Android应用程序

时间:2014-02-21 19:41:30

标签: java android eclipse google-app-engine sockets

我按照https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae的说明在本地测试我的应用程序。在步骤6中,我使用真实设备而不是使用模拟器。我收到以下错误:

java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8888) after 20000ms
    at libcore.io.IoBridge.connectErrno(IoBridge.java:159)
    at libcore.io.IoBridge.connect(IoBridge.java:112)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
    at java.net.Socket.connect(Socket.java:842)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
    at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
    at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
    at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)

我有什么想法可以解决这个问题?我看到this answer但不知道如何实施他们的解决方案(如果有的话)。我正在使用eclipse juno和app-engine插件。

我右键单击了我的项目,何时运行Config以查看是否有可以更改的内容,我不确定我会更改或添加的内容。

更新

更改为0.0.0.0后,我在android中将LOCAL_APP_ENGINE_SERVER_URL设置为什么?我在链接的帖子中尝试了几乎所有的响应,但我仍然得到同样的错误。所以我想我必须要在android本身做一个改变。

实际上我有时会得到错误日志(在0.0.0.0更改之后)

java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080) after 20000ms: isConnected failed: ECONNREFUSED (Connection refused)
 java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080) after 20000ms: isConnected failed: ECONNREFUSED (Connection refused)
    at libcore.io.IoBridge.isConnected(IoBridge.java:224)
    at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
    at libcore.io.IoBridge.connect(IoBridge.java:112)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
    at java.net.Socket.connect(Socket.java:842)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
    at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
    at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
    at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964)
    at  at libcore.io.IoBridge.isConnected(IoBridge.java:224)
    at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
    at libcore.io.IoBridge.connect(IoBridge.java:112)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
    at java.net.Socket.connect(Socket.java:842)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)

0 个答案:

没有答案