2
votes

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
Are you testing against a deployed App Engine project or on the local server? If your project is deployed, change the line LOCAL_ANDROID_RUN = true to LOCAL_ANDROID_RUN = false.Floris
I am testing locally, so I have my LOCAL_ANDROID_RUN set as trueDivya
I believe you are testing on a handset as opposed to using an emulator. Use an emulator; you'll skip a lot of hurdles. For starters, the address listed (10.0.2.2) is used by the emulator-your device won't recognise itkakoma

1 Answers

4
votes

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.