skif48 / nabbitmq

Node.js library for interacting with RabbitMQ based on RxJS streams
MIT License
19 stars 2 forks source link

Adding vhost in rabbitmq connection string fails #5

Closed marcio199226 closed 5 years ago

marcio199226 commented 5 years ago

Hi,

When i tried to add a vhost to my connection string the connection fails with the following error:

Error: Error while connecting to RabbitMQ: Expected ConnectionOpenOk; got

This is my connection string: amqp://guest:guest@localhost:5672/vhostname

I havae tried setting connection options through setOptions resulting with the same error reported above:

  connectionFactory.setOptions({
    username: 'guest',
    password: 'guest',
    hostname: 'localhost',
    port: '5672',
    vhost: '/vhostname',
    protocol: 'amqp'
  })

I followed this spec https://www.rabbitmq.com/uri-spec.html.

Thanks in advance for any replies.

marcio199226 commented 5 years ago

Ok maybe i figured out the problem, before declaring a vhost in connection string / options this virtual host should be created first. I thought that this happens automatically but i didn't find anything about it on ampqlib's doc

this is by design, we can only create vhost from cli or from api through rabbit's management panel, this feature is not a part of amqp protocol if I understood properly, nervermind we may close this issue