Open haolian9 opened 3 years ago
A client connection can be closed cleanly or abnormally. In the former case the client closes AMQP 0-9-1 (or 1.0, or STOMP, or MQTT) connection gracefully using a dedicated library function (method). In the latter case the client closes TCP connection or TCP connection fails. RabbitMQ will log both cases.
according to the docs of rabbitmq, it seems AmqpProtocol just simply close the underlying socket connection, without sending a proper close signal(?) to rabbitmq first.
Abruptly closed connections can be harmless.
althrough, i think implemeting the "normal close" is still good to have.
I agree and it should close cleanly (when not crashing). I'll look into it (though it'll be a couple weeks before I can get to it). Pull requests welcome. ;-)
according to the amqp 0-9-1 reference, there is a connection.close()
command which corresponding to pamqp.commands.Connection.Close()
.
after dived into the code, and i think it could be caused by the following code:
Protocol.close():
# see: https://github.com/python-trio/trio-amqp/blob/dd805fc93e668b4ae094609d4afefa4561e64ae4/async_amqp/protocol.py#L228
await self.connection_closed.set()
if not got_close:
# ...
# see: https://github.com/python-trio/trio-amqp/blob/dd805fc93e668b4ae094609d4afefa4561e64ae4/async_amqp/protocol.py#L248
await self.wait_closed()
# which simply call `self.connection_closed.wait()`
since connection_closed is always set before waiting, the later wait() does not work as expected.
I agree and it should close cleanly (when not crashing). I'll look into it (though it'll be a couple weeks before I can get to it). Pull requests welcome. ;-)
Was this fixed? Or can I work on it?
reproduce: (just copied from examples/send.py)
env:
logs at the rabbitmq side:
rabbitmq complains
client unexpectedly closed TCP connection
.as comparison, i tried pika, and here is rabbitmq's logs