My server sents GCM request to the GCM api for the push notification.The push notification works fine for some couple of push notification, after that the curl function which is making the request is getting timed out with the following error
"Curl failed: Failed to connect to android.googleapis.com port 443: Connection timed out"
without any response.But the response code is 200Ok.
But again after sometime if I try it will sent the notification with a proper success response and if I try sending for sometime, to different devices it again hangs and shows the above message.
I have opened port 5228, 5229, and 5230 on my firewall.
Why does this happen.I can't figure why it is happening like this.
This is the code Im using
$headers = array(
'Authorization: key=' . $this->serverApiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $this->url );
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
// Avoids problem with https certificate
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
// Execute post
$result = curl_exec($ch);
Please help me to find a solution for this.