At the moment, if client is not able to connect to broker because of reasons like invalid credentials, port, user or anything else, broker sends the connection Close method to the amqpprox server. And amqpprox immediately shutdowns and closes the sockets for clients. Because of that, client never receives the connection Close method, which is not good for the client. Because the Close method specifies the reason behind the closing the connection abruptly and it would be hard for client to debug any existing problem. So this PR fixes that issue. And it forwards the received connection close method to client. This way client will be able to know the reason of closure during handshake. And then it continues to shutdown and close sockets. Once we have the successful connection, amqpprox will forwards complete traffic to client as usual.
For example, if any client tries to connect to any vhost using wrong credentials, amqpprox will get the connection Close method from the server. And amqpprox will forward this method to client, before shutting down the socket.
Sample received Close method on client side, which describes the correct reason of the disconnection:
Received message: MESSAGE=Connection Close = [replyCode: 403, replyText: "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.", classId: 0, methodId: 0] CHANNEL=0 LEN=119
At the moment, if client is not able to connect to broker because of reasons like invalid credentials, port, user or anything else, broker sends the connection Close method to the amqpprox server. And amqpprox immediately shutdowns and closes the sockets for clients. Because of that, client never receives the connection Close method, which is not good for the client. Because the Close method specifies the reason behind the closing the connection abruptly and it would be hard for client to debug any existing problem. So this PR fixes that issue. And it forwards the received connection close method to client. This way client will be able to know the reason of closure during handshake. And then it continues to shutdown and close sockets. Once we have the successful connection, amqpprox will forwards complete traffic to client as usual.
For example, if any client tries to connect to any vhost using wrong credentials, amqpprox will get the connection Close method from the server. And amqpprox will forward this method to client, before shutting down the socket.
Sample received Close method on client side, which describes the correct reason of the disconnection: