注册与端点服务器发生故障(App Engine的连接Android项目)故障、发生、服务器、项目

2023-09-07 14:46:07 作者:相关可爱的七个字>>

我是新来的Andr​​oid编程和谷歌应用程序引擎。我跟着下面的文档,以运行示例应用程序,它注册在我的设备: https://开头developers.google.com/eclipse/docs/endpoints-androidconnected-gae

I am new to Android programming and Google App Engine. I followed the below documentation to run a sample app which registers my device: https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae

当我运行的应用程序(在设备上),我看到以下内容:

1)报名与谷歌云消息传递......成功了!

1)Registration with Google Cloud Messaging...SUCCEEDED!

2)注册与端点服务器...失败!

2)Registration with Endpoints Server...FAILED!

无法与云终端服务器中注册您的设备。无论你的云终端服务器没有部署到应用程序引擎,或者需要改变,以针对本地实例运行在CloudEndpointUtils.java设置LOCAL_ANDROID_RUN为真设置

Unable to register your device with your cloud endpoints server. Either your cloud endpoints server is not deployed to app engine, or your settings need to be changed to run against a local instance by setting LOCAL_ANDROID_RUN to 'true' in CloudEndpointUtils.java

我还检查了LogCat中看到以下异常:

6月一号至14日:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):尝试与服务器进行注册时异常收到 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):java.net.SocketTimeoutException:无法连接到/10.0.2.2 20000后(8888端口) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.io.IoBridge.connectErrno(IoBridge.java:159) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.io.IoBridge.connect(IoBridge.java:112) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在java.net.Socket.connect(Socket.java:872) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpConnection(HttpConnection.java:76) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpConnection(HttpConnection.java:50) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpConnection $ Address.connect(HttpConnection.java:340) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.api.client.http.javanet.NetHtt prequest.execute(NetHtt prequest.java:77 ) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.api.client.http.Htt prequest.execute(Htt的prequest.java:964) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.googlecloudproject.GCMIntentService.onRegistered(GCMIntentService.java:163) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:251) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:153) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.app.IntentService $ ServiceHandler.handleMessage(IntentService.java:65) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.os.Handler.dispatchMessage(Handler.java:99) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.os.Looper.loop(Looper.java:158) 6月1日至14号:05:40.268:E / com.googlecloudproject.GCMIntentService(1831):在android.os.HandlerThread.run(HandlerThread.java:61)

01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): Exception received when attempting to register with server 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8888) after 20000ms 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.io.IoBridge.connectErrno(IoBridge.java:159) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.io.IoBridge.connect(IoBridge.java:112) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at java.net.Socket.connect(Socket.java:872) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpConnection.(HttpConnection.java:76) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpConnection.(HttpConnection.java:50) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.googlecloudproject.GCMIntentService.onRegistered(GCMIntentService.java:163) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:251) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:153) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at android.os.Handler.dispatchMessage(Handler.java:99) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at android.os.Looper.loop(Looper.java:158) 01-14 06:05:40.268: E/com.googlecloudproject.GCMIntentService(1831): at android.os.HandlerThread.run(HandlerThread.java:61)

任何人都可以提出这个时发生异常和为什么我的设备无法与云终点注册?

推荐答案

我也有类似的问题,并通过设置解决了这个问题。

I had a similar problem and solved it by setting

LOCAL_APP_ENGINE_SERVER_URL = "http://[myLocalIp]:8888"

其中, myLocalIp 是IPv4的地址,你可以通过打开找到 CMD.EXE 从你的开始菜单,写 IPCONFIG

where myLocalIp is your ipv4-address which you can find by opening cmd.exe from your start menu and writing ipconfig.

请务必编辑 CloudEndpointUtils.java 正确 SERVER_URL 字符串。我觉得它使用 LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID 默认情况下。

Make sure to edit the correct SERVER_URL string in CloudEndpointUtils.java. I think it uses LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID by default.

对于这个工作我也不得不改变运行配置为后端项目。在Eclipse中:选择服务器项目 - >右键 - >运行方式 - >运行配置。选择Arguments窗格和程序参数,添加 - 在面前地址= 0.0.0.0 - 端口= 8888

For this to work i also had to change the run configurations for the backend project. In Eclipse: select the server project -> right click -> Run as -> Run Configurations. Select the Arguments pane and in Program Arguments, add --address=0.0.0.0 in front of the --port=8888.