[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');
// 假设私钥密码被移除。
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);