title: RabbitMQ PRECONDITION_FAILED - unknown delivery tag
body: <p>We have a PHP app that forwards messages from RabbitMQ to connected devices down a WebSocket connection (PHP AMQP pecl extension v1.7.1 &amp; RabbitMQ 3.6.6).</p>
  
  <p>Messages are consumed from an array of queues (1 per websocket connection), and are acknowledged by the consumer when we receive confirmation over the websocket that the message has been received (so we can requeue messages that are not delivered in an acceptable timeframe). This is done in a non-blocking fashion.</p>
  
  <p>99% of the time, this works perfectly, but very occasionally we receive an error "RabbitMQ PRECONDITION_FAILED - unknown delivery tag ". This closes the channel. In my understanding, this exception is a result of one of the following conditions:</p>
  
  <ol>
  <li>The message has <em>already</em> been acked or rejected.</li>
  <li>An ack is attempted over a channel the message was not delivered on.</li>
  <li>An ack is attempted after the message timeout (ttl) has expired.</li>
  </ol>
  
  <p>We have implemented protections for each of the above cases but yet the problem continues. </p>
  
  <p>I realise there are number of implementation details that could impact this, but at a conceptual level, are there any other failure cases that we have not considered and should be handling? or is there a better way of achieving the functionality described above? </p>