Search code examples
phpiospush-notificationapple-push-notificationsprocessmaker

IOS Push fails with error message: fwrite(): send of 474 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host


I'm using open source app "ProcessMaker"

All works fine except IOS push notification, when acctions that makes a push, this push crash only for IOS (in android work fine).

Error:

Warning: stream_socket_client(): SSL: The operation completed successfully. in C:\Bitnami\processmaker-3.0.1.8-   0\apps\processmaker\htdocs\workflow\engine\src\ProcessMaker\BusinessModel\Light\PushMessageIOS.php on line 128

urlssl://gateway.push.apple.com:2195
err0
errstr

fpResource id #146
msg �y33I����1�� Z�^�-+�� �����{"aps":{"alert":"#85 : Travel Request, Request by: \"Jordi Ferri\"","sound":"default","data":{"processId":"14804077157da297c90a955022163281","taskId":"80166625957da297ca43bf6022283253","caseId":"39318847657e115e0176d98020370358","caseTitle":"Travel Request, Request by: \"Jordi Ferri\"","delIndex":"2","typeList":"todo","counters":{"toDo":"0","draft":"0","cancelled":"0","participated":"0","paused":"0","completed":"0","unassigned":0}}}}
len474

Notice: fwrite(): send of 474 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in C:\Bitnami\processmaker-3.0.1.8-0\apps\processmaker\htdocs\workflow\engine\src\ProcessMaker\BusinessModel\Light\PushMessageIOS.php on line 147

result0

Code:

foreach ($this->devices as $item) {
        // Open a connection to the APNS server
        $fp = stream_socket_client($this->url, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
        echo "<br />url" . $this->url;
        echo "<br />err" . $err;
        echo "<br />errstr" .  $errstr;
        echo "<br />";
        if (!$fp) {
            throw (new \Exception(\G::LoadTranslation('ID_FAILED') . ': ' . "$err $errstr"));
        } else {
            //echo 'Apple service is online. ' . '<br />';
        }

        // Build the binary notification
        $msg = chr(0) . pack('n', 32) . pack('H*', $item) . pack('n', strlen($payload)) . $payload;

        // Send it to the server
        echo "<br />fp" . $fp;
        echo "<br />msg" . $msg;
        echo "<br />len" .  strlen($msg);
        echo "<br />";
        $result = fwrite($fp, $msg, strlen($msg));
        echo "<br />result" . $result;
    }

PHPINFO

PhpInfo partial


Solution

  • this issue was already fixed for processmaker 3.1 that is being released october 4th, if after updating you still see this issue please create a ticket on http://bugs.processmaker.com/ so it can be adressed accordingly.