Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect HTTP/2 after request failed #136

Open
jonas0616 opened this issue Sep 20, 2016 · 2 comments
Open

Disconnect HTTP/2 after request failed #136

jonas0616 opened this issue Sep 20, 2016 · 2 comments

Comments

@jonas0616
Copy link

jonas0616 commented Sep 20, 2016

NFO: Process 1 has 1 messages, sending...
INFO: Sending messages queue, run #1: 1 message(s) left in queue.
ERROR: Unable to send message ID 1: {"reason":"BadDeviceToken"} (400).
INFO: Disconnected.
INFO: Trying to initialize HTTP/2 backend...
INFO: Initialized HTTP/2 backend.
INFO: Sending messages queue, run #2: 1 message(s) left in queue.
ERROR: Unable to send message ID 1: {"reason":"BadDeviceToken"} (400).
INFO: Disconnected.
INFO: Trying to initialize HTTP/2 backend...
INFO: Initialized HTTP/2 backend.
INFO: Sending messages queue, run #3: 1 message(s) left in queue.
ERROR: Unable to send message ID 1: {"reason":"BadDeviceToken"} (400).
INFO: Disconnected.
INFO: Trying to initialize HTTP/2 backend...
INFO: Initialized HTTP/2 backend.
INFO: Sending messages queue, run #4: 1 message(s) left in queue.
WARNING: Message ID 1 [custom identifier: 497] has 3 errors, removing from queue...

According to APNS document: "Normal request failures do not result in termination of a connection".
Is it overreacting that it disconnects when any request fails?

@YohannsMonnier
Copy link

Hello, we see exactly the same kind of problem. Did you find a solution about that ?

@YohannsMonnier
Copy link

The problem is on this function :

protected function _updateQueue($aErrorMessage = null)
   {
       $aStreamErrorMessage = $this->_readErrorMessage();
       if (!isset($aErrorMessage) && !isset($aStreamErrorMessage)) {
           return false;
       } else if (isset($aErrorMessage, $aStreamErrorMessage)) {
           if ($aStreamErrorMessage['identifier'] <= $aErrorMessage['identifier']) {
               $aErrorMessage = $aStreamErrorMessage;
               unset($aStreamErrorMessage);
           }
       } else if (!isset($aErrorMessage) && isset($aStreamErrorMessage)) {
           $aErrorMessage = $aStreamErrorMessage;
           unset($aStreamErrorMessage);
       }

       $this->_log('ERROR: Unable to send message ID ' .
           $aErrorMessage['identifier'] . ': ' .
           $aErrorMessage['statusMessage'] . ' (' . $aErrorMessage['statusCode'] . ').');

       $this->disconnect();

       foreach($this->_aMessageQueue as $k => &$aMessage) {
           if ($k < $aErrorMessage['identifier']) {
               unset($this->_aMessageQueue[$k]);
           } else if ($k == $aErrorMessage['identifier']) {
               $aMessage['ERRORS'][] = $aErrorMessage;
           } else {
               break;
           }
       }

       $this->connect();

       return true;
   }

I think that this is done this way because the code was shared between the two version of the library, the one working with socket and the one working with http2. With the HTTP2 version, we have doubt on the fact that doing disconnection and reconnection is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants