title: Push notification is successfully sent, but the device does not receive (occasionally)
body: <p>I have been having a problem where some devices will not receive a push notification, since yesterday.
  The certificate / device token seem to be correct,
  since the device used to successfully receive push notifications until yesterday.</p>
  
  <p>On the server-side, there are no errors or connection refusals,
  and the push notification seems to be successfully sent every time.</p>
  
  <p>But still, there are many occasions where the device does not correctly receive the push.</p>
  
  <p>Some surrounding information:</p>
  
  <ul>
  <li>I am doing this on the production environment.</li>
  <li>No errors / connection refusals on the server-side</li>
  <li>I am sending the exactly same JSON everytime.</li>
  <li>2 of our devices are not receiving the push notification AT ALL since yesterday</li>
  <li>1 of our device receives push notifications at a lower success rate (about 70%) than yesterday</li>
  <li>1~2 of our devices still receive push notifications successfully even now.</li>
  <li>All of the above devices were able to receive push notifications properly on the production environment until yesterday.</li>
  </ul>
  
  <p><strong>There is no difference in the server-side result for when the push is successful, and when the device doesn't receive it...
  Therefore it is virtually impossible to identify the problem.</strong></p>
  
  <p>This is the server-side PHP code I am using:</p>
  
  <pre><code>        $ctx = stream_context_create();
          stream_context_set_option($ctx, 'ssl', 'local_cert', $this-&gt;apnsData[$development]['certificate']);
          $fp = stream_socket_client($this-&gt;apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_C ONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
  
          if(!$fp){
                  $this-&gt;_pushFailed($pid);
                  $this-&gt;_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
          }
          else {
                  $msg = chr(0).pack("n",32).pack('H*',$token).pack("n",strlen($message)).$message;
                  $fwrite = fwrite($fp, $msg);
                  if(!$fwrite) {
                          error_log("[APNS] push failed...");
                          $this-&gt;_pushFailed($pid);
                          $this-&gt;_triggerError("Failed writing to stream.", E_USER_ERROR);
                  }
                  else {
                          error_log("[APNS] push successful! ::: $token -&gt; $message ($fwrite bytes)");
                  }
          }
          fclose($fp);
  </code></pre>
  
  <p>The log tells me that the push was successful (Cutting out the token for privacy) :</p>
  
  <pre><code>[Wed Dec 12 11:42:00 2012] [error] [client 10.161.6.177] [APNS] push successful! ::: aa4f******44 -&gt; {"aps":{"alert":{"body":"\\u300casdfasdf\\u300d","action-loc-key":"OK"},"badge":4,"sound":"chime"}} (134 bytes)
  </code></pre>
  
  <p>How do I solve this?</p>