3

I followed the instructions at:

How To Build An Apple Push Notification Provider Server When I run the php script on my MacOSX or on Windows using Parallel desktop, the script works. But as soon as I run it on my hosting I get the message:

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in provider.php on line 23
Failed to connect 110 Connection timed out 

Does this have to do with the certificates? If so how can I make a certificate that could work on the computer where my hosting is located.

Mark
  • 16,906
  • 20
  • 84
  • 117
  • i have installed the .pem certificate on the server , still then its not working.I am having the same problem as above. i am able to run in mylocal XAMPP server, but not in the external hosting server. Please help me .. – Biranchi Nov 24 '09 at 12:56

3 Answers3

4

Your hosting provider probably does not allow outbound connections to ports 2195 and 2196. Most shared hosting providers do not have those ports open. You might need to get a VPS or you can also try UrbanAirship which provides Apple Notification Service integration and is free for a certain limit per month.

pm_labs
  • 1,135
  • 12
  • 22
  • is there any way to allow these ports in cpanel ? – Ravi Jethva Jan 16 '13 at 14:36
  • @RaviJethva I'm not aware of any methods to enable them through cpanel. Your best bet will be to contact your respective providers directly and ask them if they have hosting plans which can have those ports open. – pm_labs Mar 07 '13 at 23:49
  • @Mups also noted in another answer that he was able to have the port opened by availing of a dedicated IP from the hosting provider. – pm_labs Mar 07 '13 at 23:51
1

Yes you need a certificate. THis is explained in the Apple docs. One catch, you will probably need to convert the cert to .pem format. The .pem cert needs to include both the certificate and the RSA private key.

Here is a good site to read: http://www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/

My pem looks like:

Bag Attributes
    friendlyName: Apple Development Push Services: <my data>
    localKeyID: <my local key in hexascii> 
subject=/UID=com.my.push.sandbox1/CN=Apple Development Push Services: <my data>/C=US
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
-----BEGIN CERTIFICATE-----
<my certificate data omitted>
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
<my key data omitted>
-----END RSA PRIVATE KEY-----
zaph
  • 111,848
  • 21
  • 189
  • 228
  • 1
    Thank you zaph for your response. I do have the certificates and the .pem files else it wouldn't work on my local machine, but if I upload that certificate to my hosting together with my php file. It gives the above time-out. Do I need a different certificate for on the hosting computer? Because I can only access it by FTP. – Mark Sep 19 '09 at 21:42
  • Check that the .pem file has both parts. On a local Mac it may be getting the private key from the Keychain. I am running on another machine that does not have a Keychain entry. – zaph Sep 20 '09 at 17:46
1

I found the simplest and cheapest solution was to request a dedicated IP from your hosting company. At Blue Host it was $2.50 a month. With this dedicated IP, they were willing to open ports 2195 and 2196.

Mups
  • 2,150
  • 1
  • 15
  • 9