views:

305

answers:

2

Hi developers,

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

// coonecting the apn server $apnsHost = 'gateway.sandbox.push.apple.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? plz help.

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

+2  A: 

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

Claus Broch
A: 

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

Ethel