diff --git a/.travis.yml b/.travis.yml index 130250b..0a88ea2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,8 @@ before_script: sudo service rabbitmq-server start; fi - if [ "$STOMP_PROVIDER" = 'activemq' ]; then - sudo apt install activemq tree; + sudo apt update; + sudo apt install activemq; sudo cp tests/utils/activemq.xml /etc/activemq/instances-available/main/; sudo ln -s /etc/activemq/instances-available/main /etc/activemq/instances-enabled/main; sudo service activemq start; diff --git a/README.md b/README.md index 2a79d86..f305081 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ $loop->run(); * `vhost`: Virtual host, defaults to `/`. * `login`: Login user name, defaults to `guest`. * `passcode`: Login passcode, defaults to `guest`. +* `protocol`: Protocol to connect with, defaults to `tcp` (use `tls` for TLS-enabled connections). ## Acknowledgement @@ -95,6 +96,10 @@ To run the test suite, you need PHPUnit. $ phpunit +Or, to run the functional tests against a local message queue: + + $ STOMP_PROVIDER=rabbitmq phpunit -c phpunit-functional.xml.dist + ## License MIT, see LICENSE. diff --git a/examples/config/activemq-tls.php b/examples/config/activemq-tls.php new file mode 100644 index 0000000..e8a561b --- /dev/null +++ b/examples/config/activemq-tls.php @@ -0,0 +1,10 @@ + '127.0.0.1', + 'port' => '61614', + 'login' => 'system', + 'passcode' => 'manager', + 'vhost' => '/', + 'protocol' => 'tls', +); diff --git a/src/Factory.php b/src/Factory.php index d805661..8911159 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -17,6 +17,7 @@ class Factory 'vhost' => '/', 'login' => 'guest', 'passcode' => 'guest', + 'protocol' => 'tcp', ); private $loop; @@ -51,7 +52,7 @@ public function createClient(array $options = array()) public function createConnection($options) { - $address = 'tcp://'.$options['host'].':'.$options['port']; + $address = $options['protocol'].'://'.$options['host'].':'.$options['port']; if (false === $fd = @stream_socket_client($address, $errno, $errstr)) { $message = "Could not bind to $address: $errstr"; diff --git a/tests/React/Tests/Stomp/FactoryTest.php b/tests/React/Tests/Stomp/FactoryTest.php index d26b56c..e3fb635 100644 --- a/tests/React/Tests/Stomp/FactoryTest.php +++ b/tests/React/Tests/Stomp/FactoryTest.php @@ -13,7 +13,7 @@ public function testCreateConnection() $loop = $this->createMock('React\EventLoop\LoopInterface'); $factory = new Factory($loop); - $conn = $factory->createConnection(array('host' => 'localhost', 'port' => 37234)); + $conn = $factory->createConnection(array('host' => 'localhost', 'port' => 37234, 'protocol' => 'tcp')); $this->assertInstanceOf('React\Socket\Connection', $conn); } @@ -25,7 +25,7 @@ public function itShouldThrowAnExceptionInCaseSocketCreationFails() $factory = new Factory($loop); try { - $factory->createConnection(array('host' => 'localhost', 'port' => 37235)); + $factory->createConnection(array('host' => 'localhost', 'port' => 37235, 'protocol' => 'tcp')); $this->fail('This should have raised an exception'); } catch (ConnectionException $e) {