私のプロジェクトには約500人のiOSユーザーがいます。プッシュ通知を送信すると、次のエラーが表示されます。いくつかのトークン件までAPNS with PHP with SSL broken pipeエラー
Severity: Warning
Message: fwrite(): SSL: Broken pipe
Message: fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:ssl3_write_pending:bad write retry
正しい働き0を結果として最初のトークンから無効なトークンに上記error.Isにそれを示しているので、整数にeg.181結果?.Iは、生産と開発のトークンを区別望めません助けてください。事前にお礼します。 私のコード
public function connectApns(){
try{
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert',$_SERVER['DOCUMENT_ROOT'].'/webservice/application/libraries/ck.pem');
stream_context_set_option($ctx, 'ssl','passphrase', '1234');
$this->fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if($this->fp){
return TRUE;
}else{
echo $errstr;
return FALSE;
}
}
catch(Exception $e1){
echo $e1->getMessage();
}
}
public function iOS($data,$columnName){
$ids = array();
$tokens = array();
$sql = "SELECT user_id FROM tp_notification WHERE ";
if($columnName == "job"){
$sql = $sql." job = 1";
}
if($columnName == "hostel"){
$sql = $sql." hostel = 1";
}
if($columnName == "event"){
$sql = $sql." event = 1";
}
if($columnName == "bazar"){
$sql = $sql." bazar = 1";
}
if($columnName == "share"){
$sql = $sql." share = 1";
}
if($columnName == "court"){
$sql = $sql." court = 1";
}
if($columnName == "contest"){
$sql = $sql." contest = 1";
}
if($columnName == ""){
$sql = "SELECT user_id FROM tp_notification";
}
$query = $this->CI->db->query($sql);
if($query){
$mid_result = $query->result_array();
foreach ($mid_result as $value)
{
$ids[] = $value['user_id'];
}
if(count($ids) > 0){
$sql1 = "SELECT device_token FROM tp_user WHERE user_id IN ? AND device_type = ? AND user_active = ? ORDER BY user_id DESC";
$query1 = $this->CI->db->query($sql1,array($ids,'iOS',1));
if($query1){
$mid_result1 = $query1->result_array();
foreach ($mid_result1 as $key)
{
$tokens[] = $key['device_token'];
}
}
}
}
if(count($tokens) > 0){
$isConnected = $this->connectApns();
if ($isConnected){
for($i = 0; $i < count($tokens); $i++){
$sql5 = "SELECT badge FROM tp_user WHERE device_token = ?";
$query5 = $this->CI->db->query($sql5,array($tokens[$i]));
$badge = 0;
if($query5){
$mid_result5 = $query5->row();
$badge = $mid_result5->badge + 1;
}
$body['aps'] = array(
'alert' => array(
'title' => $data['title'],
'body' => $data['data'],
'type'=>$data['type'],
'id'=>$data['id']
),
'content-available'=>1,
'badge'=>$badge,
'sound' => 'default'
);
$deviceToken = $tokens[$i];
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
try{
if(strlen($deviceToken) == 64){
$result = fwrite($this->fp, $msg, strlen($msg));}
if($result){
$sql6 = "UPDATE tp_user SET badge=? WHERE device_token=?";
$query6 = $this->CI->db->query($sql6,array($badge,$tokens[$i]));
}else{
fclose($this->fp);
sleep(5);
$this->connectApns();
}
} catch(Exception $e){
fclose($this->fp);
sleep(3);
$this->connectApns();
}
}
fclose($this->fp);
}
}
}
質問に関連するコードを含めてください。 –
私のコードは上に示されています –