使用APNS 搭建苹果推送服务器错误:unable to connect to ssl://gateway.sandbox.push.apple.com:2195 错误

1:检查你的服务器的端口 2195是否已经开启,是否被关闭了或是防火墙阻止了!这点很重要;

如果你不确定,又出现了错误,请先向你的服务器商询问一下,并开启;

2:确认你的证书没有问题:

在mac下执行 openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key-noenc.pem -debug -showcerts -CAfile "apns-dev.pem"

在上面进程执行完之后;可以随便输入一些字符串,如果关闭了,这时是正常的!如果没有关闭,会有错误信息打印;说明证书有问题;

证书生成:https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/

3:检查你的 推送程序是否有问题;

在这里推荐几个我测试成功的 php推送程序;

  • https://github.com/blommegard/APNS-Pusher
  • https://github.com/duccio/ApnsPHP
  • https://github.com/manifestinteractive/easyapns
  • 其他:
    <?php//接收到设备发来的token,这里我手动填上。
    $deviceToken = "c9d15180ff117c6540e0f21f8c13edae6a5a437e517acbac7bb740fd33b9b069";
    //构造消息体
    $body = array("aps" => array("alert" => 'this is test from push.cocoajin.org/p.php', "badge" => 1, "sound" => 'received5.caf'));
    $ctx = stream_context_create();
    stream_context_set_option($ctx, "ssl", "local_cert", "apns-dev.pem");
    //建立socket连接
    $fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
    if (!$fp) { print "Failed to connect $err $errstrn"; return; }
    print "Connection OK";
    $payload = json_encode($body);
    $msg = chr(0) . pack("n",32) . pack("H*", $deviceToken) . pack("n",strlen($payload)) . $payload;
    print "sending message :" . $payload . "\n";
    fwrite($fp, $msg);
    fclose($fp);?>
    

      

4:检查你的服务器与推送程序的环境配置是否相匹配;

比如我的服务器使用Apache ,程序用php 那么 就要确认服务器 支持php 的 socket连接 openSSL模块;

unable to connect to ssl://gateway.sandbox.push.apple.com:2195 错误相关推荐

  1. C028: Unable to Connect to the Siebel Gateway Name Server

    C028: "Unable to Connect to the Siebel Gateway Name Server" Logged By Configuration Wizard ...

  2. WARN RestSubmissionClient: Unable to connect to server spark://master:

    完整报错如下: $ spark-submit --class WordCountLocal --deploy-mode cluster  --driver-memory 1g --executor-m ...

  3. fatal: unable to connect to gitee.com: gitee.com[0: 180.97.125.228]: errno=Unknown error

    fatal: unable to connect to gitee.com: gitee.com[0: 180.97.125.228]:errno=Unknown error 致命:无法连接到gite ...

  4. 学习laravel5,Win7安装Composer-Setup.exe,出错ERR_CONNECTION:Unable to connect to getcomposer.org

    下载 Composer-Setup.exe 后安装出错: Composer Download Error Connection Error [ERR_CONNECTION]: Unable to co ...

  5. Unable to connect to the Redgate Client Service

    今天在使用ssms17同步数据库时,打开后就显示 Unable to connect to the Redgate Client Service 错误,然后看着提示信息就是license过期了,其实已 ...

  6. 解决安装svn后出现Unable to connect to a repository at URL以及认证失败

    首先在ubuntu下安装了svn :(ubuntu安装在虚拟机中) sudo apt-get install subversion 然后创建了一个库: mkdir /home/lyh/svn cd / ...

  7. eclipse安装SVN插件报错Unable to connect

    [help]-> install new sofeware- -> install窗口的work with填写:http://subclipse.tigris.org/update_1.1 ...

  8. Unable to Connect: sPort: 0 C# ServiceStack.Redis 访问 redis

    需求:  对数据库中的不断抓取的文章进行缓存,因此需要定时访问数据,写入缓存中 在捕获到的异常日志发现错误:Unable to Connect: sPort: 0 使用的访问方式是线程池的方式:Poo ...

  9. TortoiseSVN Unable to connect to a repository at URL XXX

    在Checkout资源库时,出现如下错误: Unable toconnectto a repositoryat URL XXX Error Unable to connect to a reposit ...

  10. 问题解决:错误:unable to connect to node rabbit@localhost: nodedown

    OpenStack错误:Error: unable to connect to node rabbit@localhost: nodedown 问题来源:rabbitmq添加用户失败 思考原因 1.翻 ...

最新文章

  1. python基础知识整理 第七节:单例设计模式、异常、模块、包、制作模块、文件
  2. meteor从入门到精通_我已经大规模运行Meteor一年了。 这就是我所学到的。
  3. 公共交通伸展城市智慧
  4. 全国农商互联暨精准扶贫产销对接 对话农民丰收节交易会
  5. Ajax异步请求登录
  6. matplotlib练习
  7. python财务预算分析_财码Python管理会计小实验—营运管理之多维度盈利能力分析...
  8. iOS之深入解析谓词NSPredicate的语法与应用
  9. [6]Windows内核情景分析 --APC
  10. Most Powerful
  11. python安装多个版本_Mac安装多个python版本
  12. c语言数字游戏程序,C语言实现数字游戏
  13. Idea利用JSP模板设置统一路径(basePath)
  14. 云脉H5文档管理系统之文件管理的共享与协作
  15. android+imei+为null,适合Android7.0以上(到9.0)系统,获取 关于手机--状态信息 (如:MAC,IMEI,IMSI,ICCID)...
  16. Leetcode小白上线第三十三天
  17. cmd命令打开文本文档_win10自带照片应用打开太慢,改用win7照片查看器
  18. 国内人工智能行业全梳理
  19. StreamNative 宣布 2300 万美元 A 轮融资,Prosperity7 Ventures 与华泰创新联合领投
  20. [乐意黎]phpQuery采集微信公众号文章乱码

热门文章

  1. 在pcb放置坐标标注_PCB拼板上的那颗美人痣
  2. CSDN-markdown编辑器语法说明
  3. 估计理论(1):最小方差无偏估计(第2章)
  4. 再谈KMP/BM算法(II)
  5. MacOS 迅速上手 Makefile 编译 C / C++ 工程
  6. Linux进程优先级取值范围,Linux中使用nice和renice命令:改变进程优先级
  7. vue 事件调用 传参_高效开发小程序,Vue 和微信小程序的区别你该了解一下
  8. oracle表内连接和外连接
  9. javascript事件委托和jQuery事件绑定on、off 和one以及on绑定多个事件(重要)
  10. 解决iOS app集成共享QQ场地,微信的朋友,朋友等功能圈,不能采用苹果公司的审计问题...