简体   繁体   English

尝试发送IOS推送通知时出现错误“ 111连接被拒绝”(在我的本地环境中有效,但不在线)

[英]Getting error “111 Connection refused” when try to send IOS push notification (works at my local environment but not online)

When I run the following script local, it sends push notifications to any device but when I run it in server I have this error: 当我在本地运行以下脚本时,它将推式通知发送到任何设备,但是当我在服务器中运行它时,出现此错误:

111 Connection refused 111连接被拒绝

Php code: 邮递区号:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class PushNotification extends CI_Controller
{

function __construct()
{
    parent::__construct();
    $this->load->helper('url');
}

function index()
{

    $deviceToken = '64X';

    $message = 'My first push notification!'.'<ahref="http://google.com">Google.com</a>';

    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem');
    //stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

    $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 120, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);

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

    $body['aps'] = array(
        'alert' => $message,
        'sound' => 'default'
    );
    $payload = json_encode($body);
    $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

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

    if (!$result)
        echo 'Message not delivered' . PHP_EOL;
    else
        echo 'Message successfully delivered' . PHP_EOL;

    fclose($fp);

}

}//end of class

答:我向主机发送了一条消息以打开传出端口(出站),他们做到了,并且此代码正常工作:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 推送通知错误111连接被拒绝 - Push notification Error 111 connection refused Apple推送通知不能在我的godaddy共享服务器上工作,它的throght无法连接111连接拒绝php推送通知错误 - Apple Push Notification is not working on my godaddy shared server, it's throght failed to connect 111 connection refused php push notification error 推送通知(iPhone)给出“111 Connection refused” - Push notifications (iPhone) give “111 Connection refused” PHP fsockopen错误,连接被拒绝(111),尝试使用TCP / IP连接指纹设备 - PHP fsockopen error, connection refused(111), try to connect fingerprint device using TCP/IP 在symfony 2中发送电子邮件时出错[连接被拒绝#111] - Error sending emails in symfony 2 [Connection refused #111] PHP发送推送通知无法连接:111连接被拒绝 - PHP Sending Push Notifications Failed to connect: 111 Connection refused Swiftmailer:连接被拒绝 #111 - Swiftmailer: Connection refused #111 当我尝试使用其他设备连接到本地的自定义wordpress安装时出现err_connection_refused(Xampp) - err_connection_refused when i try to connect to my custom wordpress installation on local, using other device (Xampp) SMTP错误:无法连接到服务器:连接被拒绝(111)错误消息 - SMTP ERROR: Failed to connect to server: Connection refused (111) ERROR MESSAGE SMTP - &gt;错误:无法连接到服务器:连接被拒绝(111) - SMTP -> ERROR: Failed to connect to server: Connection refused (111)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM