Apns php error “Failed to connect to APNS: 110 Connection timed out.”

末鹿安然 提交于 2019-12-30 18:56:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!