If value passed to 'x-message-ttl' is greater than or equal 128, then invalid Negative value is sending to server
Steps to reproduce
If try something like this (pass 128 value):
transport, protocol = await aioamqp.connect(**rabbit)
channel: Channel = await protocol.channel()
arguments = {'x-message-ttl': 128}
await channel.queue_declare(queue_name='foo', durable=True, arguments=arguments)
Then this error happened:
aioamqp.exceptions.ChannelClosed: (406, "PRECONDITION_FAILED - invalid arg 'x-message-ttl' for queue 'foo' in vhost '/': {value_negative,-128}")
And if try with 129 value:
transport, protocol = await aioamqp.connect(**rabbit)
channel: Channel = await protocol.channel()
arguments = {'x-message-ttl': 129}
await channel.queue_declare(queue_name='foo', durable=True, arguments=arguments)
Then this error happened:
aioamqp.exceptions.ChannelClosed: (406, "PRECONDITION_FAILED - invalid arg 'x-message-ttl' for queue 'foo' in vhost '/': {value_negative,-127}")
130 -> -126
131 -> -125 etc..
Environment
OS: MacOS 10.14
Python: 3.7.3
Package version: aioamqp==0.13.0
RabbitMQ 3.7.13 on Erlang 21.3
I also found similar issues for client libraries in other languages. For example, this one for NodeJS:
https://github.com/squaremo/amqp.node/issues/165
They resolved it by this way https://github.com/squaremo/amqp.node/pull/166/files
Also this bug is reproduced in aio-pika, when I switched the code to it.
Hello @vartagg
since a few versions we've migrated the frame encoding and decoding to pamqp : https://github.com/gmr/pamqp
imho we should open an issue there. Spec says : https://www.rabbitmq.com/ttl.html
The value of the TTL argument or policy must be a non-negative integer (0 <= n), describing the TTL period in milliseconds. Thus a value of 1000 means that a message added to the queue will live in the queue for 1 second or until it is delivered to a consumer. The argument can be of AMQP 0-9-1 type short-short-int, short-int, long-int, or long-long-int.
since a few versions we've migrated the frame encoding and decoding to pamqp : https://github.com/gmr/pamqp
imho we should open an issue there.
Hi @dzen I need to do some investigations of this library and AMQP protocol itself, for be able to properly describe the issue in low-level terms.