Routing key length is not validated
- Dominant language
- C++
- Stars
- 106
- Forks
- 32
- Avg merge
- 9h 4m
- Merged PRs (30d)
- 6
Description
The topic exchange routing key has a limitation of 255 bytes (see https://www.rabbitmq.com/tutorials/tutorial-five-go#:~:text=There%20can%20be%20as%20many,be%20in%20the%20same%20form.). However, this limitation is not applied when binding queue to an exchange or sending the message:
**To Reproduce**
1. Specify a long routing key (>255 characters) when binging a queue to an exchange:
`topology.bind(exchange, queue, longRoutingKey);`
No errors will be reported but the process will hang forever.
2. Specify a long routing key (>255 characters) when sending the message:
`producer->send(message, longRoutingKey, ...);`
The following error will be reported:
`13JAN2025_08:46:10.559653 350290 140737331340864 WARN /home/pasick/github/pasick-clean/rmqcpp/src/rmq/rmqio/rmqio_asioconnection.cpp 410 UNINITIALIZED_LOGGER_MANAGER Socket closed: Connection reset by peer. Current state: 1`
and the connection will be closed.
Please refer to the attached sample which demonstrates the issue:
[longRoutingKeyIssue.txt](https://github.com/user-attachments/files/18396782/longRoutingKeyIssue.txt)
**Expected behavior**
I believe that the size of the routing key should be validated and do not accept values larger that 255 bytes.
Contributor guide
Assessment
This issue has not been assessed yet.