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

Watch after Reserve not working #8

Closed
apmcodes opened this issue Jan 23, 2019 · 3 comments
Closed

Watch after Reserve not working #8

apmcodes opened this issue Jan 23, 2019 · 3 comments

Comments

@apmcodes
Copy link

In the below code, first reserve command is run and then watch command after 2 secs, but watch command callback is never run.

Is watch not allowed after reserve, so is the reserve is hanging blocking the connection and no further command is run? Is this the way beanstalkd works or is this this client library ...

const Beanstalkd = require('beanstalkd').default;

let client = new Beanstalkd('127.0.0.1', 11300);
client.connect().then(function (client) {
    console.log('going to reserve');
    client.reserve()
        .then(function (err, jobid, payload) {
            if (err) { console.log(err) }
            console.log(`Job Id ${jobid}`);
            console.log(`Job data ${payload.toString()}`);
            client.destroy(jobid, function (err) {
                if (err) { console.log(err) }
                console.log(`Job deleted ${jobid}`);
            });
        });
})

setTimeout(() => {
    console.log('going to watch')
    client.watch('low-volume')
        .then((tubecount) => {
            console.log(tubecount);
        })
        .catch(err => {
            console.log(err);
        })
}, 2000)

setTimeout(function () {
    console.log("Hello");
}, 3000);

Output

going to reserve
going to watch
Hello

@apmcodes apmcodes changed the title Watch after Reserv not working Watch after Reserve not working Jan 23, 2019
@apmcodes
Copy link
Author

Seems as beanstalkd reserve is blocking call, other commands such as watch/ ignore are hanging. Is there way to watch while the client is still in reserve?

@mickhansen
Copy link
Contributor

mickhansen commented Jan 24, 2019

That's simply how the protocol works @apmcodes, you can't use reserve and watch on the same connection.

Each instance of this library handles a single connection, it's up to you to manage them or use a higher level library

@apmcodes
Copy link
Author

Thank you for the clarification.

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

No branches or pull requests

2 participants