0

My data-center appears to have had some issues with their network and thus my server has suffered from on an off network connectivity for about an hour.

After the connection has been completely re-established my code still kept reporting the same issue over and over until I have restarted the service.

The code is a simple PHP code that loops forever checking the Apple feed-back server and then sleeps for a few minutes and then it begins all over again.

Now I understand the error being generated if the network is down but once it got back up why did it continue until I have restarted the code? Does PHP have something that needs to be re-initialized or something??

Messges log:

Dec 20 08:57:22 server kernel: r8169: eth0: link down
Dec 20 08:57:28 server kernel: r8169 0000:06:00.0: eth0: link up
Dec 20 08:57:29 server kernel: r8169: eth0: link down
Dec 20 08:57:33 server kernel: r8169 0000:06:00.0: eth0: link up
Dec 20 08:57:33 server kernel: r8169: eth0: link down
Dec 20 08:57:37 server kernel: r8169 0000:06:00.0: eth0: link up
Dec 20 08:57:38 server kernel: r8169: eth0: link down
Dec 20 08:57:44 server kernel: r8169 0000:06:00.0: eth0: link up
Dec 20 08:57:44 server kernel: r8169: eth0: link down
Dec 20 08:57:52 server kernel: r8169 0000:06:00.0: eth0: link up
Dec 20 08:57:52 server kernel: r8169: eth0: link down
Dec 20 09:10:58 server kernel: r8169 0000:06:00.0: eth0: link up

PHP Error:

PHP Warning:  stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/push/feedback.php on line 36

Code Line 36:

$apns = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $errcode, $errstr, 60, STREAM_CLIENT_CONNECT, $stream_context);

1 Answer 1

1

My guess is DNS caching.

The error message getaddrinfo failed: Name or service not known indicates that there was a DNS error, either an NXDOMAIN response or a SERVFAIL. I assume this happened while the network was down and the response was cached, causing it to continue to fail once the network as back up.

These two responses are allowed to be cached, although not usually as long as positive responses. NXDOMAIN responses can be cached for the SOA minimum time (often between 600 and 3600 seconds), SERVFAIL response for no more than 300 seconds.

Restarting your service may have flushed the cache or it may have been a coincidence that you restarted it at the same time as the cache expired naturally. I don't know of any internal PHP DNS cache so I'm leaning towards the latter option. If it happens again or if you are reproducing the problem in order to debug it, try using dig feedback.sandbox.push.apple.com to narrow your tests down to just the DNS lookup.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .