1

I'm following the Android GCM Demo tutorial (http://developer.android.com/google/gcm/demo.html) and I'm attempting to get the application to work on my Android phone however whenever I run the application on the phone I receive the message: Trying (attempt 1/5) to register device on Demo Server

Then after 5 failed attempts, I get the error message: Could not register device on Demo Server after 5 attempts

I am running the GCM Server before trying to run the application, and the GCM Server is running on my local laptop. The following server values have been set in my "CommonUtilities" file in the "app" folder in the GCM-Demo-Client project.

SERVER_URL = "http://192.168.1.100:8080/gcm-demo";
SENDER_ID = "245619476079";

I am aware that this is an internal IP address, however I ran into other issues trying to run the server on my external IP address, and I have got my Android device connected to the same WI-FI network, so I'm unsure why this isn't working.

Help please :).

P.S. If anyone has any advice how to get the GCM-Demo-Server running on my external IP address that would be great! At the moment the only external IP address I can find for my machine is the IP of the wireless modem/router, which only allows me to access the modem/router options (even if I make the GCM-Demo-Server run on that external IP address).

Ice Phoenix
  • 1,001
  • 3
  • 16
  • 34
  • I'm guessing you're using Tomcat as your webserver, so if you enter 192.168.1.100:8080 from your phone's browser, do you see the Tomcat welcome page? – NickT Mar 06 '13 at 13:40
  • To use the external ip address, then you will need to set the router to 'port forward' from port xxxx to port 8080 on your demo server. You will the access the server as your_address_or_hostname:xxxx. – NickT Mar 06 '13 at 13:51
  • Thanks for the response Nick, I'm actually using the Java AppEngine running on my standard Windows8 laptop as my "Webserver", just for development and testing purposes. Is it possible to run Tomcat on a non-Server machine? Also, thanks for that info regarding the router, I'll definitely give that a go with the router settings when I get home. – Ice Phoenix Mar 07 '13 at 00:43
  • Just had a thought, I haven't adjusted the Android manifest file with the GCM permision settings yet, could this be preventing the phone from being able to successfully contact the GCM Server? I am using the project provided with the GCM-Demo so i would assume the correct settings would already be in the manifest file, but I'll have to check. – Ice Phoenix Mar 07 '13 at 03:35
  • Using an internal ip-address should work fine, I do this all the time. Fix the GCM permissions and see if that helps. Also, it might be interesting to note that I have created a maven plugin that contains a test server for you: https://code.google.com/p/gcmutils/wiki/MavenPlugin – Jarle Hansen Mar 07 '13 at 07:37
  • Just checked and he Android manifest is already correct, so that's not the cause of the issues, is there any further settings/steps I might be missing? – Ice Phoenix Mar 07 '13 at 08:46

3 Answers3

1
SERVER_URL = "http://192.168.1.10:8080";

use this url, it will register on page: http://192.168.1.10:8080/home, not the page http://192.168.1.10:8080/gcm-demo , and can't send message.

0

Finally managed to work out the issue. Unsure why but after removing "/gcm-demo" from the end of the URL, my device was able to successfully connect to the GCM Server and receive messages. So the final "SERVER_URL" set within the "CommonUtilities.java" file appears as:

SERVER_URL = "http://192.168.1.100:8080";

Also thanks for the tips Nick, managed to get it working my external IP address with port forwarding, making the final SERVER_URL look like:

SERVER_URL = "http://<external_ip>:8080";

Thanks for your help guys :)

Ice Phoenix
  • 1,001
  • 3
  • 16
  • 34
0

Make Sure curl is enabled in php. It Works For Me.

For example, with Ubuntu/Debian server, you need to run this command:

sudo apt-get install php5-curl

After that, restart the Apache server:

sudo /etc/init.d/apache2 restart

with Windows try enabling from wamp settings.

For more on enabling curl refer this

Community
  • 1
  • 1
karanatwal.github.io
  • 3,613
  • 3
  • 25
  • 57