doudui2229 2013-05-21 05:03
浏览 22
已采纳

移动到EC2实例后,APNS推送不工作,而不是“失败”

So, I moved my application to an EC2 instance, and Apple Push Notification Service stopped working. I'm using the same certificate, same script, same everything.

  • I've opened port 2195 in the security group for the EC2 instance.
  • from the EC2 intance, telnet gateway.push.apple.com 2195 works
  • my script receives no errors... everything gets to the end, even fwrite returns true... yet, I receive no push.

Things to note.

  • My EC2 instance is accessed via https where my old server was http, but since the script would be running locally, and has nothing to do with Apache, I don't see why this should matter. But, perhaps it does, so I'm letting you know :D

My script:

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$ssl = 'ssl://' . $apnsHost . ':' . $apnsPort;
$apns = stream_socket_client($ssl, $error, $errorString, 30, STREAM_CLIENT_CONNECT, $streamContext);
if($apns == false){
    echo "Error: $errorString";
    return false;
}
$payload['aps'] = array('alert' => $message, 'badge'=>$badge, 'sound' => 'default');
$payload = json_encode($payload);

$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $device_id)) . chr(0) . chr(strlen($payload)) . $payload;
if(fwrite($apns, $apnsMessage)){
    return true;
}
return false;

I've checked all of my variables, they are set.

Any help would be greatly appreciated. This is driving me bonkers :P

  • 写回答

1条回答 默认 最新

  • dongqixuan3112 2013-05-29 20:27
    关注

    Turns out I was giving a bad device id. The databases were different, and I stored something poorly. :(

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效