4

Problem: I cannot access APNS server. I get a 110 Connection Time Out error.

My situation:

  1. I've contacted my host (hostmonster). They said my port 2195,2196 are already open.
  2. My certificate and passphrase is no problem, for I've tested it from my local Mac.
  3. I use a very simple PHP to test. Here's my code:

    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'apn.pem');
    stream_context_set_option($ctx, 'ssl', 'passphrase', 'aaa');
    $fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err,     
          $errstr,60,STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,$ctx);
    
    if ($fp)
        echo ('aa');
    else
        echo ($err.$errstr);
    
Flexo
  • 87,323
  • 22
  • 191
  • 272
Van
  • 41
  • 1
  • 5

1 Answers1

10

I had the same exact problem, but with Bluehost. In my case, it turned out the Bluehost firewall was not properly open. The first line chat support from Bluehost said the ports 2195 & 2196 are open, and the problem was not with them. To demonstrate the problem was on their side, I asked them to run the following telnet command from the Bluehost server:

telnet gateway.push.apple.com 2195

Trying 17.149.36.246...
Trying 17.149.35.166...
Trying 17.149.35.170...
Trying 17.149.35.177...
... Connection timed out

The output should be:

telnet gateway.push.apple.com 2195

Trying 17.149.36.230...
Connected to gateway.push.apple.com.
Escape character is '^]'.

Then i submitted a support ticket to Bluehost with this information. They resolved the issue in 6 hours by properly opening the firewall.

Greg Viot
  • 101
  • 1
  • 6