Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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);
share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.