使用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. 关于svn获取获取文件时 Unable to connect to a repository at URL"https://..."执行上下文错误:参数错误

    错误提示: 下面的六种解决方案都未能解决: 1.不提示输入用户名和密码,不管重装多少次都一样. 2.TortoiseSVN的setting->Saved Data->Authenticat ...

  2. codeigniter教程:Codeigniter出现Unable to connect to your databas

    Codeigniter出现A Database Error Occurred错误 下午把项目构建到服务器上的时候,codeigniter竟然出现了 a database error occurred ...

  3. Unable to process request: General SSLEngine problem.Unable to connect to neo4j at `localhost:7687`, because the certificate the server uses has changed.

    Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Unable to proce ...

  4. Unable to connect to web server 'IIS Express'(无法连接到Web服务器“IIS Express”)的解决方式-Jexus Manager

    在运行微软示例工程eShopOnWeb时候, 在经过一段时间再运行启动报Error "Unable to connect to web server 'IIS Express'"  ...

  5. 【API管理 APIM】APIM集成内部VNet后,自我访问出现(Unable to connect to the remote server)问题,而Remote Server正是APIM它自己

    问题描述 在使用APIM配置内部VNET后,如API-1正常配置访问后端服务器的一个接口,而API-2则是通过调用APIM中的API-1来作为backendUrl,会出现500错误. 经过测试,目前这 ...

  6. telnet报“Unable to connect to remote host:Connection refused”错误

    Linux下面telnet ip 端口号 报错误"Unable to connect to remote host:Connection refused"的时候,大部分是目标机的端 ...

  7. svn检出的时候报 Unable to connect to a repository at URL错误(摘自CSDN)

    背景:1.         SVN服务器:VisualSVN-Server-2.5.5: 2. SVN客户端:TortoiseSVN-1.7.6.22632-x64-svn-1.7.4.msi: 在S ...

  8. Error: unable to connect to node rabbit@mail: nodedown

    某天,开启一个应用时,发现连接rabbitmq失败,本来想用rabbitmqctl来查看队列,结果提示“Error: unable to connect to node rabbit@mail: no ...

  9. SVN Unable to connect to a repository at UR

    背景: 1.         SVN服务器:VisualSVN-Server-2.5.5: 2.         SVN客户端:TortoiseSVN-1.7.6.22632-x64-svn-1.7. ...

随机推荐

  1. 关于ARM的开发环境IAR工程的配置问题

    1设置路径使IAR能够自动关联你的头文件 a.将自己的头文件..c文件..s文件放在不同的文件当中.(此处的.C文件和.S文件以及头文件都是开始一个项目所必须有的文件.例如每一个项目都需要对UArt串 ...

  2. Python标准库:内置函数divmod(a, b)

    本函数是实现a除以b,然后返回商与余数的元组. 如果两个参数a,b都是整数,那么会采用整数除法,结果相当于(a//b, a % b).如果a或b是浮点数,相当于(math.floor(a/b), a% ...

  3. AtCoder - 3954 Painting Machines

    题面在这里! 题解见注释 /* 考虑一个可以用 K ((n+1)/2 <= K < n)次染黑的方案, 那么将操作前K次的机器从小到大排序,一定是: a1=1 < a2 < . ...

  4. 【强连通分量缩点】【DFS】【动态规划】Urozero Autumn Training Camp 2016 Day 5: NWERC-2016 Problem B. British Menu

    有向图,不经过重复点的最长链,强连通分量大小不超过5. 每个强连通分量内部暴力预处理任意两对点之间的最长路,外面DAG上dp. 不是很好写,但是预处理完了之后,可以重构每个强连通分量内部的结构,然后整 ...

  5. view加阴影和边框

    UIImageView *imgvPhoto  = [UIImageView alloc] init]; //添加边框   CALayer *layer = [_imgvPhoto layer];   ...

  6. Problem E: 十六进制转十进制

    #include<stdio.h> int main(void) { ]; int sum,i; while(gets(str)!=NULL) { sum=; ;str[i]!='\0'; ...

  7. Windows下编译protobuf v3.3.0

    一:概述 关于 protobuf 在此不再多说,此处记录下成功编译步骤以备日后查阅.注意:本文并不是使用cmake gui进行编译的,如果熟悉cmake gui的话,也可以使用gui进行生成编译. 二 ...

  8. trim()函数 mysql中的强大字符串过滤函数

    mysql中功能强大的trim()函数. 去除两边空格: mysql> select trim(' hello world '); +-----------------------+ | tri ...

  9. (Mark=转)ehcache memcache redis

    Ehcache 在java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS中取出来的高花费.高延迟采取的一种缓存方案.正因为Ehcache具有健壮性(基于java开发).被认证(具有apa ...

  10. iOS笔记,得到一个控件的坐标

    [showBtn.superView  convertRect:showBtn.frame toView:nil]: 参数从后往前理解: toView-->指的目标控件的坐标需要在哪个view上 ...