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

Microservices - rabbitmq options #5587

Closed
capaio opened this issue Oct 20, 2020 · 6 comments
Closed

Microservices - rabbitmq options #5587

capaio opened this issue Oct 20, 2020 · 6 comments
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@capaio
Copy link

capaio commented Oct 20, 2020

Feature Request

Is your feature request related to a problem? Please describe.

if you use a rabbitmq password that has a slash it is impossible to connect:

 const user = 'username'
  const pwd = 'nGasd!56J/-)Q6'
  const host = 'localhost';
  const port = 5672;

  const microservicePayment = app.connectMicroservice<MicroserviceOptions>({
    transport: Transport.RMQ,
    options: {
      urls: [`amqp://${user}:${pwd}@${host}:${port}`],
      queue: 'queuename',
      queueOptions: {
        durable: false
      },
    },
  });

you get this error:

{
"err": {
  "cause": {
     "errno": -3001,
      "code": "EAI_AGAIN",
       "syscall": "getaddrinfo",
      "hostname": "username"
    },
     "isOperational": true,
     "errno": -3001,
     "code": "EAI_AGAIN",
     "syscall": "getaddrinfo",
     "hostname": "username"
 }
}

Describe the solution you'd like

At the moment the interface of rabbitmq option is:

export interface RmqOptions {
    transport?: Transport.RMQ;
    options?: {
        urls?: string[];
        queue?: string;
        prefetchCount?: number;
        isGlobalPrefetchCount?: boolean;
        queueOptions?: any;
        socketOptions?: any;
        noAck?: boolean;
        serializer?: Serializer;
        deserializer?: Deserializer;
        replyQueue?: string;
    };
}

the option 'urls' is an array of strings. But it should be possible to use objects instead of string as described in
https://www.squaremobius.net/amqp.node/channel_api.html#connecting-with-an-object-instead-of-a-url

{
  protocol: 'amqp',
  hostname: 'localhost',
  port: 5672,
  username: 'guest',
  password: 'guest',
  locale: 'en_US',
  frameMax: 0,
  heartbeat: 0,
  vhost: '/',
}

it would be very useful to use this object too instead of just strings. LIke this:

interface RmqUrl {
    protocol?: string;
    hostname?: string,
    port?: number,
    username?: string,
    password?: string,
    locale?: string,
    frameMax?: number,
    heartbeat?: number,
    vhost?: string,
}

export interface RmqOptions {
    transport?: Transport.RMQ;
    options?: {
        urls?: string[] | RmqUrl[];
        queue?: string;
        prefetchCount?: number;
        isGlobalPrefetchCount?: boolean;
        queueOptions?: any;
        socketOptions?: any;
        noAck?: boolean;
        serializer?: Serializer;
        deserializer?: Deserializer;
        replyQueue?: string;
    };
}

I have tried editing the code as I showed and it works proprerly

I edited the report several times to make it more clear, sorry if this made you confuse

@capaio capaio added needs triage This issue has not been looked into type: enhancement 🐺 labels Oct 20, 2020
@jmcdo29
Copy link
Member

jmcdo29 commented Oct 20, 2020

Would you like to create a PR to update the acceptable types?

@capaio
Copy link
Author

capaio commented Oct 20, 2020

Yes, It would be a pleasure!

@kamilmysliwiec
Copy link
Member

Let us know if you need anything from us to proceed @capaio! 💪

@capaio
Copy link
Author

capaio commented Oct 29, 2020

I have opened a PR #5609

@kamilmysliwiec
Copy link
Member

My fault, thanks @capaio! I haven't noticed it

@kamilmysliwiec
Copy link
Member

Fixed in 7.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

3 participants