开发者

can not connect the apples APN server for pusNotification from by PHP code

To connect my server with the APN server I use the following code.

// coonecting the apn server
$apnsHost = 'gateway.sandbox.push.a开发者_Python百科pple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $errorNo, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);

But I am failed to connect, I print the $errorNo and $errorString the output was: error: Connection timed out errorNo: 110

But I am also getting the following warnings in errorLog:

Unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in /home/riseupla/public_html/applications/apn/apn.php on line 35

What shoud I do?

NOTE: I can send push notifications by my mac project (using push me baby project). But my PHP project failed to connect.


You do not say if you run the php from a different machine than your Mac, but if you are using a hosted service for your php site, then it might be that the ISP has blocked port 2195 (and 2196).

Try to run your php on the same machine as you use when running your Mac project and see if this helps. If that's the case, then you ISP has most likely blocked the ports, and you will have to either find a different ISP or have them open the ports.

Claus


You probably solved it.

But for those interested to find out if the ports are blocked: IF you have SSH access to the server a simple way is to check if you can telnet to the server. This way i found out my provider blocked the ports...

:~ telnet gateway.sandbox.push.apple.com 2195
:~ telnet gateway.sandbox.push.apple.com 2196

You should see something like:

Trying 17.172.232.236...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.


may be that your server's IP variety, it must be fixed so work!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜