Skip to content

AMQPSocketConnection has a different parameters order, lets consider it #527

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

Merged
merged 2 commits into from
May 2, 2018

Conversation

goetas
Copy link
Contributor

@goetas goetas commented Feb 16, 2018

AMQPSocketConnection has a different parameter ordering than AMQPStreamConnection

Currently the example on how to use sockets connection does not work.
You will always get

[PhpAmqpLib\Exception\AMQPIOException]                      
Error reading data. Received 0 instead of expected 7 bytes  

To solve is necessary to pass read_timeout = 0 or a higher value to the AMQPSocketConnection class.

I guess this can be "solved" by connection_parameters_provider, but since sockets looks to be supported natively by the bundle they should work almost out of the box.

Ive spent days trying to setup socket connections.

@goetas
Copy link
Contributor Author

goetas commented Feb 16, 2018

What surprises me is also that most of the people here as solution for the Error reading data. Received 0 instead of expected 7 bytes suggest using streams instead of disabling the read timeout.

Are there different ways to use AMQPSocketConnection ?

@goetas
Copy link
Contributor Author

goetas commented Feb 16, 2018

3a5e688 allows to pass generic parameters to constructors allowing to use all other types of connection present in https://github.com/php-amqplib/php-amqplib/tree/master/PhpAmqpLib/Connection

@goetas
Copy link
Contributor Author

goetas commented Mar 21, 2018

Any feedback on this?

@skafandri
Copy link
Collaborator

Would you mind adding one test for constructor_args and one for the AMQPSocketConnection case (first if branch)

@goetas
Copy link
Contributor Author

goetas commented May 2, 2018

sure! will do soon

@@ -211,6 +269,28 @@ public function testSSLConnectionParameters()
), $instance->constructParams);
}

public function testConnectionsParametersProviderWithConstructorArgs()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests covers already constructor_args. the clas name has to be OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection, using any other connection will try to connect to rabbitmq

return $ref->newInstanceArgs($this->parameters['constructor_args']);
}

if ($this->class == 'PhpAmqpLib\Connection\AMQPSocketConnection' || is_subclass_of($this->class , 'PhpAmqpLib\Connection\AMQPSocketConnection')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not know really how to test this since will try to connect to rabbtmq

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I forgot it extends from AbstractConnection

@goetas
Copy link
Contributor Author

goetas commented May 2, 2018

Left two comments. is not really clear to me which other tests should be added. Can you provide more info?

@skafandri skafandri merged commit 92c17e6 into php-amqplib:master May 2, 2018
@goetas
Copy link
Contributor Author

goetas commented May 2, 2018

:) great, thanks

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

Successfully merging this pull request may close these issues.

2 participants