Setting custom connection name via client_properties doesn't work when connecting using an amqp:// URL
See original GitHub issueRepro:
import asyncio
import aio_pika
async def main():
# named connection using URL (works)
abc_conn = await aio_pika.connect("amqp://localhost?name=ABC")
# named connection using client properties (doesn't work)
def_conn = await aio_pika.connect("amqp://localhost",
client_properties={'connection_name': 'DEF'})
# named connection using kwargs only (works)
xyz_conn = await aio_pika.connect(host="localhost", name='XYZ')
input('hit enter to close connections...')
for conn in [abc_conn, def_conn, xyz_conn]:
await conn.close()
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
Expected:
https://aio-pika.readthedocs.io/en/latest/apidoc.html#aio_pika.connect only gives the client_properties example of setting the connection name, so it’s not obvious that it won’t work when using a URL to connect, and the trick of using a name query parameter doesn’t seem to be documented anywhere (only figured it out by reading through aiormq code).
Actual:
The snippet above will set the connection name in the RabbitMQ management UI as expected for ABC and XYZ, but not DEF.
Environment:
$ pip freeze
aio-pika==6.5.2
aiormq==3.2.1
idna==2.9
multidict==4.7.5
pamqp==2.3.0
yarl==1.4.2
Plus RabbitMQ 3.8.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Set connection name with amqplib - node.js - Stack Overflow
Yes you can set the connection name by passing it in the client properties: amqp.connect('amqp://localhost', {clientProperties: ...
Read more >Connections - RabbitMQ
This guide covers various topics related to connections except for network tuning or most networking-related topics. Those are covered by the Networking and ......
Read more >Connection Parameters — pika 1.2.1 documentation
Set the tcp options for the underlying socket. Parameters: url (str) – The AMQP URL to connect to. ssl_options ...
Read more >ConnectionFactory (RabbitMQ Java Client 5.15.0 API)
Most connection and socket settings are configured using this factory. ... be configured here and will apply to all connections produced by this...
Read more >Spring AMQP
As a result, you need not use that bean explicitly in the simple Java ... When using a large number of connections, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m using aio-pika 8.2.3 and I don’t think it’s fixed,
aio_pika.connect(...)andaio_pika.connect_robust(...)passclient_propertiesonly tomake_url(...)and that function just returns the URL when given. Probably, when manually instantiatingConnectionandRobustConnection, passingconnection_nameworks, but not for this methods.EDIT: After trying over and over again and debugging all over the 3 libraries, I’ve managed to set a custom name only without specifying the URL and by setting the property
name, NOTconnection_name.i.e.:
For anyone waiting on this, it is fixed in the newly released aio-pika 7.x