GithubHelp home page GithubHelp logo

Comments (8)

ebadia avatar ebadia commented on August 11, 2024 1

@AlariCode Sorry, my fault... I did not upgrade the package to incude the changes... Now the error message has disapeared. Thanks!

from nestjs-rmq.

AlariCode avatar AlariCode commented on August 11, 2024

@ebadia, thanks for report! I'll look into this issue. I think I'll need to add additional check in package.

from nestjs-rmq.

ebadia avatar ebadia commented on August 11, 2024

Thanks for making this work so well with nestjs! Just as an idea, I saw that in connect you only return the resolve case, perhaps rejecting the promise could help.

from nestjs-rmq.

AlariCode avatar AlariCode commented on August 11, 2024

@ebadia, I updated package to 0.1.1 with better connection management system.

Now you can catch error on client:

try {
       return this.client.send<string, string>({ cmd: 'test' }, msg);
} catch (err) {
      console.log('Error:' + err);
 }

And server and client will reconnect when RMQ server will be available (if it was down):
image

Furthermore, I added support for clustering. You can specify more then one url on client or server:

client = new ClientRMQ({
    urls: [`amqp://login:password@host`],
    queue: 'test',
    queueOptions: { durable: false }
}); 

Please note that now you need to use urls option instead of url and pass string[] instead of string.

from nestjs-rmq.

ebadia avatar ebadia commented on August 11, 2024

That's great, I'll give it a try. Thanks.

from nestjs-rmq.

ebadia avatar ebadia commented on August 11, 2024

@AlariCode this solves the error problem when sending the message. And for sure it's great. But the system still returns an error message when I try to do the new ClientRMQ

(node:54282) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:5672

It seems that we have an unhandled promise rejection there too. This does not stops the app and the try/catch you have added helps a lot. But perhaps this "warning" should be considered for the future.

from nestjs-rmq.

AlariCode avatar AlariCode commented on August 11, 2024

@ebadia this is strange. It connects only when first message is sent. This code:

const client = new ClientRMQ({
            urls: [`amqp://${config.default.localhost.amqp.login}:${config.default.localhost.amqp.password}@${config.default.localhost.amqp.host}`],
            queue: 'test',
            queueOptions: { durable: false },
        });

doesn't cause client to connect. And this one does:

this.client.send<string, string>({ cmd: 'test' }, msg);

Could you please show you code with error? This example catches an error perfectly:

@Controller()
export class AppController {
    client = new ClientRMQ({
        urls: [`amqp://${config.default.localhost.amqp.login}:${config.default.localhost.amqp.password}@${config.default.localhost.amqp.host}`],
        queue: 'test',
        queueOptions: { durable: false },
    });

    @Get('a')
    a(): Observable<string> {
        try {
            return this.client.send<string, string>({ cmd: 'test' }, 'test');
        } catch (err) {
            console.log('Got error: ' + err);
        }
    }
}

from nestjs-rmq.

AlariCode avatar AlariCode commented on August 11, 2024

Thanks for bug report! I’m closing this issue.

from nestjs-rmq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.