问题
I have done apns code for php and objective c from this Apns code
and setup certificate from this link
Sandbox and production apns for sending notification to ios devices is working perfectly on my server.I moved code and same certificate to client server then sending notification is not working.
I debug all php code and found that it stops at this line of code
private function _connectSSLSocket($development) {
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
$this->sslStreams[$development] = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
if(!$this->sslStreams[$development]){
$this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
unset($this->sslStreams[$development]);
return false;
}
return $this->sslStreams[$development];
}
apns.log file shows the error "Failed to connect to APNS: 110 Connection timed out."
Not getting the mistake. Why this error am i getting and not sending notification to ios devices ? Can anyone guide me for this ?
回答1:
Finally i took vps instead of shared hosting. Lucabro's comments helped me to solve. Thanks Lucabro.
回答2:
A good solution is to use a cloud function like firebase to run the actual apns connection and expose an API for your other backend in the shared hosting. This is what I used when I run in this problem.
Firebase cloud functions are convenient easy to develop and virtually free.
https://firebase.google.com/docs/functions
I'll post my solution to sometimes next week.
来源:https://stackoverflow.com/questions/19025488/apns-php-error-failed-to-connect-to-apns-110-connection-timed-out