[Tue Feb 05 00:16:13 2013] [error] [client 112.11.122.37] PHP Warning: stream_socket_client(): unable to connect to ssl://17.149.38.141:2195 (Connection timed out) in /chroot/updateapp_push.php on line 72
[Tue Feb 05 00:16:13 2013] [error] [client 112.11.122.37] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /chroot/updateapp_push.php on line 87
[Tue Feb 05 00:16:13 2013] [error] [client 112.11.122.37] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /chroot/updateapp_push.php on line 90
我向超过3000台设备的多台设备发送推送通知时遇到上述错误。有任何处理它的建议吗?
代码数量在循环中的代码:
//私钥密码(ck.pem文件)
$pass = 'push';
//从http get或命令行
获取参数 $message = 'Application(s) update available';
//$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];
$badge = $count_update;
//$sound = $_GET['sound'] or $sound = $argv[3];
//构造通知有效载荷
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;
/* End of Configurable Items */
$payload = json_encode($body);
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ckappmart.pem');
//假设已删除私钥passphase。
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://17.172.238.221:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
//print "Failed to connect $err $errstrn";
}
else {
//print "Connection OKn";
}
if($num_getNonMdmPushToken!=0) {
for($count=0;$count<1;$count++) {
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken[$count])) . pack("n",strlen($payload)) . $payload;
//print "sending message :" . $payload . "n";
fwrite($fp, $msg);
}
}
fclose($fp);