苹果推送通知反馈服务PHP脚本获取TIMEOUT每一次, [英] PHP script for Apple Push Notification FEEDBACK service gets TIMEOUT every time,

查看:305
本文介绍了苹果推送通知反馈服务PHP脚本获取TIMEOUT每一次,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候大家!
我目前正在落实反馈服务,为苹果推送通知。我有推动部全部完成,无论在沙箱和分发应用程序的工作。然而,反馈服务似乎不起作用。每一次我尝试使用我的函数..页面以及..只是得到一个超时。

Greetings everyone! I'm currently implementing the Feedback service for Apples Push notifications. I've got the pushing part all done and working both on sandbox and on distribution apps. However the feedback service seems to not work.. Each time i try to use my function.. the page well.. just gets a timeout.

我跟着这个答案让我的功能:<一href=\"http://stackoverflow.com/questions/1278834/php-technique-to-query-the-apns-feedback-server/2298882#2298882\">PHP技术查询的APN反馈服务器

I followed this answer to make my function : PHP technique to query the APNs Feedback Server

下面是我的全部功能code:

Here is my full function code :

function checkFeedbackServer($appBundle,$useDev = TRUE)
{
    $apnsPort = 2195;
    $apnsCert = keyForApp($appBundle,$useDev);

    if($useDev)
    {
        echo 'FEEDBACK in DEVELOPER MODE <br/>';
        $apnsHost = 'feedback.sandbox.push.apple.com';
    }
    else
    {
        echo 'FEEDBACK in DISTRIBUTION MODE <br/>';
        $apnsHost = 'feedback.push.apple.com';
    }
    $finalPath = 'ssl://' . $apnsHost . ':' . $apnsPort;

    echo 'OPENING STREAM TO -> ' . $finalPath . '<br/>';
    echo 'USING CERT : ' . $apnsCert . "<br/>";


    $stream_context = stream_context_create();
    stream_context_set_option($stream_context, 'ssl', 'local_cert', $apnsCert);

    $apns = stream_socket_client($finalPath, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $stream_context);

    if(!$apns) 
    {
        echo "ERROR $errcode: $errstr\n";
        return;
    }
    else echo 'APNS FEEDBACK CONNECTION ESTABLISHED...<br/>';

    $feedback_tokens = array();    
    $count = 0;

    echo 'error= ' . $error . '<br/>';
    echo 'errorString= ' . $errorString . '<br/>';

    if(!feof($apns))
        echo 'APNS NOT FINISHED <br/>';
    else
        echo 'APNS FINISHED? <br/>';    

    $result = fread($apns, 38);
    echo 'result= ' . $result;
    fclose($apns);
}

我注意到,如果我删除行:

I noticed that if i remove the lines :

$result = fread($apns, 38);
echo 'result= ' . $result;

然后,该函数正常工作。因此,在nuthsell我能开到的反馈服务的生产和开发,但只要我尝试从服务器获取任何数据我的脚本只是超时..

The function then works properly. So in a nuthsell I am able to open a connection to the feedback service both production and developer but as soon as I try to get any data from the server my script just times out..

且功能 keyForApp($的appbundle,$ useDev)只是围绕查询到我的数据库获取正确的证书一个简单的包装。我保函它的作品,因为我也使用它,而推动信息设备。

also the function keyForApp($appBundle,$useDev) is just a simple wrapper around a query to my database that fetches the correct certificate. I guarante it works since I am also using it while pushing messages to the device.

推荐答案

解决吧..原来我有错误的端口。
为了澄清:

Solved it.. Turns out I had the wrong port. To clarify :


  1. 端口 2195 是推动信息

  2. 端口 2196 是获得反馈

  1. port 2195 is for pushing messages
  2. port 2196 is for getting feedback

我的坏..;)我是混合两者结合起来,并连接到反馈服务器的端口2195,而不是2196

my bad..;) I mixed the two together and was connecting to the feedback server on port 2195 instead of 2196

这篇关于苹果推送通知反馈服务PHP脚本获取TIMEOUT每一次,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆