You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I am trying to connect to rabbitmq server with aio_pika and use tls to protect the connection, but I am encountering and ConnectionResetError with no other explanation. I was wondering if anyone can help me with some error fix tips.
I ubuntu system and created my rabbitmq service using docker. The certificate generation and image configuration files are as follows:
Dockerfile:
FROM rabbitmq:3.13-management
# copy rabbitmq.config to container
COPY rabbitmq.config /etc/rabbitmq/rabbitmq.config
# copy tls certificates and key to container
COPY rabbitmq-server-cert.pem /etc/rabbitmq/certs/rabbitmq-server-cert.pem
COPY rabbitmq-server-key.pem /etc/rabbitmq/certs/rabbitmq-server-key.pem
COPY ca-certificate.pem /etc/rabbitmq/certs/ca-certificate.pem
# expose ports for RabbitMQ server
EXPOSE 5671 5672 15672
# Start RabbitMQ server
CMD ["rabbitmq-server"]
As with the image booting smoothly, I currently have normal access to the control panel via port 15672 and normal activity via port 5672.
Executing rabbitmq-diagnostics listeners command yields the following result, which according to my understanding means that port 5671 has been successfully loaded and protected by tls.
root@82029c15869e:/# rabbitmq-diagnostics listeners
Asking node rabbit@82029c15869e to report its protocol listeners ...
Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 15692, protocol: http/prometheus, purpose: Prometheus exporter API over HTTP
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: 0.0.0.0, port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Interface: 0.0.0.0, port: 5671, protocol: amqp/ssl, purpose: AMQP 0-9-1 and AMQP 1.0 over TLS
Use nc localhost 5671 command to check that port 5671 is listening for connections.
On this basis, I would like to make a basic connection test using aio_pika
Traceback (most recent call last):
File "C:\Program Files\Python\Python310\lib\site-packages\aiormq\connection.py", line 455, in connect
reader, writer = await asyncio.open_connection(
File "C:\Program Files\Python\Python310\lib\asyncio\streams.py", line 48, in open_connection
transport, _ = await loop.create_connection(
File "C:\Program Files\Python\Python310\lib\asyncio\base_events.py", line 1103, in create_connection
transport, protocol = await self._create_connection_transport(
File "C:\Program Files\Python\Python310\lib\asyncio\base_events.py", line 1133, in _create_connection_transport
await waiter
ConnectionResetError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\USER\Downloads\Tesging\test2.py", line 44, in <module>
asyncio.run(main())
File "C:\Program Files\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\USER\Downloads\Tesging\test2.py", line 24, in main
connection = await aio_pika.connect(
File "C:\Program Files\Python\Python310\lib\site-packages\aio_pika\connection.py", line 388, in connect
await connection.connect(timeout=timeout)
File "C:\Program Files\Python\Python310\lib\site-packages\aio_pika\connection.py", line 118, in connect
self.transport = await UnderlayConnection.connect(
File "C:\Program Files\Python\Python310\lib\site-packages\aio_pika\abc.py", line 671, in connect
connection = await cls.make_connection(
File "C:\Program Files\Python\Python310\lib\site-packages\aio_pika\abc.py", line 659, in make_connection
connection: aiormq.abc.AbstractConnection = await asyncio.wait_for(
File "C:\Program Files\Python\Python310\lib\asyncio\tasks.py", line 408, in wait_for
return await fut
File "C:\Program Files\Python\Python310\lib\site-packages\aiormq\connection.py", line 918, in connect
await connection.connect(client_properties or {})
File "C:\Program Files\Python\Python310\lib\site-packages\aiormq\base.py", line 164, in wrap
return await self.create_task(func(self, *args, **kwargs))
File "C:\Program Files\Python\Python310\lib\site-packages\aiormq\abc.py", line 44, in __inner
return await self.task
File "C:\Program Files\Python\Python310\lib\site-packages\aiormq\connection.py", line 462, in connect
raise AMQPConnectionError(*e.args) from e
aiormq.exceptions.AMQPConnectionError
[Finished in 3.5s]
I tried to load the tls certificate using the ssl module that comes with python stl, and it didn't report an error, so maybe that means there's nothing wrong with the connection part of the code. Does anyone know the cause of the problem?
===
Upd:
I tried to follow the checking procedure in the rabbitmq documentation to test the availability of the certificate using the openssl self-composition loop, and got a result that showed that the certificate itself works fine.
Start Time: 1717278872
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
Max Early Data: 0
===
Upd:
Trying to connect directly to port 5671 using s_client. Observing the information returned from the port, the connection seems to be established successfully. However, the connection fails immediately and does not reflect in the logs that a connection was attempted, as described in the official documentation.
client stdout
root@user-ubuntu:~/RabiBridge/config# openssl s_client -connect localhost:5671 -cert rabbitmq-server-cert.pem -key rabbitmq-server-key.pem -CAfile ca-certificate.pem
CONNECTED(00000003)
405726C2087D0000:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:../ssl/record/rec_layer_s3.c:308:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 300 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---
The text was updated successfully, but these errors were encountered:
Hi all, I am trying to connect to rabbitmq server with
aio_pika
and use tls to protect the connection, but I am encountering andConnectionResetError
with no other explanation. I was wondering if anyone can help me with some error fix tips.I ubuntu system and created my rabbitmq service using
docker
. The certificate generation and image configuration files are as follows:Dockerfile:
create_image.sh
As with the image booting smoothly, I currently have normal access to the control panel via port 15672 and normal activity via port 5672.
Executing
rabbitmq-diagnostics listeners
command yields the following result, which according to my understanding means that port 5671 has been successfully loaded and protected by tls.Use
nc localhost 5671
command to check that port 5671 is listening for connections.On this basis, I would like to make a basic connection test using
aio_pika
Got the following trace log:
I tried to load the tls certificate using the
ssl
module that comes with python stl, and it didn't report an error, so maybe that means there's nothing wrong with the connection part of the code. Does anyone know the cause of the problem?===
Upd:
I tried to follow the checking procedure in the rabbitmq documentation to test the availability of the certificate using the openssl self-composition loop, and got a result that showed that the certificate itself works fine.
server side command:
client side command:
stdout:
===
Upd:
Trying to connect directly to port 5671 using s_client. Observing the information returned from the port, the connection seems to be established successfully. However, the connection fails immediately and does not reflect in the logs that a connection was attempted, as described in the official documentation.
client stdout
The text was updated successfully, but these errors were encountered: