du90093662774150 2018-11-16 03:39
浏览 130

fwrite():SSL操作失败,代码为OpenSSL错误消息: error:1409F07F:SSL例程:SSL3_WRITE_PENDING

I have got some problem and tried all suggestion but no help. I am not getting what is the error. Everything is to be going perfect but when call fwrite() then it will give error and stop further execution.

If anyone has an idea about it, please share with us. Thanks.

Here is my function that i am using for send push notification to iOS using PHP laravel:

function send_custom_IOSNotification($registatoin_ids, $finalArrayVal, $title, $env = false) {   
$passphrase = '1234';  
$ctx = stream_context_create();
$path = storage_path();  
if($env) {  
    stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/apns-dev-cert.pem');
} else {  
    stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/pushcert.pem');
}

stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'cafile', $path.'/entrust_2048_ca.cer'); 

if($env) {
    $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
} else {
    $fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
}

if (!$fp)
    exit("Failed to connect: $err $errstr" . PHP_EOL);

$arrlength=count($registatoin_ids); 

Log::useFiles(storage_path().'/logs/notification.log');

for($x=0;$x<$arrlength;$x++)
{
    $finalArrayVal['aps'] = array(
                'alert' => $title,
                'badge' => $registatoin_ids[$x]['badge'],
                'sound' => 'default'
            );

    foreach($finalArrayVal as $key => $value){
        $finalArrayVal[$key] = array_map('strval', $finalArrayVal[$key]);
    }

    updateUserBadges($registatoin_ids[$x]['user_id'],$registatoin_ids[$x]['badge']);
    $payload = json_encode($finalArrayVal);
    $msg = chr(0) . pack('n', 32) . pack('H*', $registatoin_ids[$x]['device_id']) . pack('n', strlen($payload)) . $payload;

    $result = fwrite($fp, $msg, strlen($msg));

    if (!$result) {
        Log::info('Message not delivered at '.$x);
        fclose($fp);
        if($env) {
            $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
        } else {
            $fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
        }
    } else {
        Log::info('Message successfully delivered at '.$x);
    }
}
fclose($fp) }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。