Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing an incorrect vhost does not result in throwing an exception #19

Closed
michalzielanski opened this issue Sep 10, 2020 · 1 comment
Closed

Comments

@michalzielanski
Copy link

When we pass an invalid vhost, the broker sends a ConnectionCloseFrame and terminates the connection, but Ridge does not capture this frame and does not throw an exception.
Example:

use Amp\Loop;
use PHPinnacle\Ridge\Client;

Loop::run(function () {
    $client = Client::create('amqp://guest:guest@localhost:5672/unknown-vhost');

    yield $client->connect();

    echo "Execution will never get here. Nor will an exception be thrown.";

    // (...)
});

This code:

asyncCall(function () {
    yield $this->await(Protocol\ConnectionCloseFrame::class);

    // (...)
});

should be in front of:

ridge/src/Client.php

Lines 122 to 124 in adcced8

yield $this->connectionStart();
yield $this->connectionTune();
yield $this->connectionOpen();

and should respond appropriately depending on the reason for closing the connection.
If we pass the wrong vhost replyCode is 530 (decimal) and replyText "NOT_ALLOWED - vhost unknown-vhost not found".

Additionally, the status change to STATE_DISCONNECTING and STATE_NOT_CONNECTED is missing in the code below.

ridge/src/Client.php

Lines 126 to 141 in adcced8

asyncCall(function () {
yield $this->await(Protocol\ConnectionCloseFrame::class);
$buffer = new Buffer;
$buffer
->appendUint8(1)
->appendUint16(0)
->appendUint32(4)
->appendUint16(10)
->appendUint16(51)
->appendUint8(206)
;
$this->connection->write($buffer);
$this->connection->close();
});

@mmasiukevich
Copy link
Contributor

24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants