Chaman Saini February 2016

Not able to connect my app server to GCM's CCS using XMPPHP

Like push-notification(downstream message), I want to implement upstream messaging from my android device to my app server in php. I am using this XMPPHP library from Github to connect my app server to GCM's CCS. But when I try to execute below code to connect GCM's CCS:

include 'XMPPHP/XMPP.php';
$conn = new XMPPHP_XMPP('gcm-preprod.googleapis.com', 5236, '<myProjectId>@gcm.googleapis.com', '<myApiKey>', 'xmpphp', 'http://myserverdomain', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_INFO);
$conn->autoSubscribe();
$vcard_request = array();
try {
  $conn->connect();
...

I am getting following error.

1455354076 [INFO]: Connecting to tls://gcm-preprod.googleapis.com:5236 1455354106 [ERROR]: Could not connect. Could not connect before timeout.

Answers


gerardnimo February 2016

How CCM will know about where(which app server) to send the upstream message? As there is no explanation in provided documentation.

I think you missed the part in the documentation where it says:

To initiate an upstream message, the client app sends a request containing the following:

  • The address of the receiving app server, in the format SENDER_ID@gcm.googleapis.com.
  • A message ID that should be unique per sender ID.
  • The message data comprising the key/value pairs of the message's payload.

You need to specify the SENDER_ID to know which server you are sending to. Sender ID is a project number acquired from the API console

How to handle the upstream message in PHP? As I am using PHP in backend.

This thread might help you. Read the comments in the accepted answer.

It says that in order to use PHP you need to look for a library that supports XMPP protocol.

Post Status

Asked in February 2016
Viewed 1,764 times
Voted 12
Answered 1 times

Search




Leave an answer