GCM Error when hosting on my own server

flyingbag

Member
Licensed User
Longtime User
Hi,
I am following the steps in the GCM tutorial

If i use the B4a hosted server and all the scripts as mentioned in the example - i have no problems in registering the device and getting a test message back. Great!

PROBLEM:
Now i did the following:
- setup a linux server on my intranet and httpd + php + mysql
- edited the PHP script and set the database name / user / password .
-changed the board url value in the device app to match the location of my hosted php file

I can now successfully register my device "TestDeviceName" on my own server and database

However - when I try to send message to my device:

java -cp b4a_gcm.jar anywheresoftware.b4a.c2dm.C2DM send TestDeviceName DUMMYMSG

I get the following error:

java.lang.RuntimeException: Error=InvalidRegistration,name=TestDeviceName removed from database.
at anywheresoftware.b4a.c2dm.C2DM.sendMessageTo(C2DM.java:67)
at anywheresoftware.b4a.c2dm.C2DM.main(C2DM.java:218)

I am not sure what is happening and cannot debug the C2DM class..any help appreciated. As i said - i am getting the "Registration Successful" message on my local server...but not sure why i cant get the message..
 

flyingbag

Member
Licensed User
Longtime User
You mean update the config.txt file? Or is there something else that needs to be done?
If you can explain this a bit that would be helpful...
Abhi
 
Upvote 0

Frank R. Nichols

Member
Licensed User
Longtime User
I am having problems somewhat similar to flyingbag.
Followed the tutorial, downloaded the sample files
registered everything with Google and ran the device APP to register its name OK (got my registered okay message)
desktop tool worked great, got my toast message (PUSH came through just fine).
I would say it was a total success.

So - I tried to move things to my own server
1. edited c2dm_board.php to have MY servername, URL, and passwords and FTP'd that php file to my server
2. edited config.txt likewise
3. edited GCM\Device\Push\Objects\src\anywheresoftware\b4a\samples\push\main.java to contain MY URL
4. re-ran the PushExample.b4a project
5. downloaded to my Galaxy Note II
Now it won't register.
...and when I run b4a_gcm.bat I get
java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect
at anywheresoftware.b4a.c2dm.C2DM.getIdForName<C2DM.java:98>
at anywheresoftware.b4a.c2dm.C2DM.sendMessageTo<C2DM.java:48>
at anywheresoftware.b4a.c2dm.C2DM.main<C2DM.java:218>


(I'm a 30-years experience embedded programmer, strong in ASM and ANSI C - very new to Android. Never used MySQL or any .php script before.)

Thanks for your patience.

My log shows:
LogCat connected to: 42f7........c7
---beginning of /dev/log/main
---beginning of /dev/log/system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
startService: class com.openflow.us.push.pushservice
** Service (pushservice) Create **
** Service (pushservice) Start **
** Service (pushservice) Start **
startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Start **
......(and here's where the error occurs, I think)....
org.apache.http.conn.HttpHostConnectException: Connection to http://firstGCM.db.113 .. 73.hostedresource.com refused
...


So I will go and see why that may have happened - password?

The good news is that the URL does indeed seem to point to my server/database
 
Last edited:
Upvote 0
Top