Registration with Endpoints Server FAILED (App Engine connected Android Project)

吃可爱长大的小学妹 提交于 2020-01-04 23:01:06

问题


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

When I run the app(on a device), I see the following:

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

2)Registration with Endpoints Server...FAILED!

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

I also checked the LogCat and see the following exception:

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)

Can anyone suggest on when this exception occurs and why my device is not able to register with cloud end points?


回答1:


I had a similar problem and solved it by setting

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

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

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.

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.



来源:https://stackoverflow.com/questions/21116314/registration-with-endpoints-server-failed-app-engine-connected-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!