0

Github repo for reproducing problem Run localhost:3000 to trigger the problem.

I am using the node-celery npm packages on the server side of Meteor 1.4.4.1. When Meteor starts, the client automatically calls the Meteor method estimates.request which triggers the server to sdd a task to queue:

client/main.js

Meteor.startup(() => {
    Meteor.call('estimates.request', function(err) {
        console.log('ok')
    })
});

which triggers the Meteor method:

imports/api/Estimates.js

Meteor.methods({
    'estimates.request'() {
        console.log('estimates.request called');

        // Create Celery client
        var celery = require('node-celery')
        var client = celery.createClient({
            CELERY_BROKER_URL: 'amqp://192.168.1.26:5672//',
            CELERY_RESULT_BACKEND: 'amqp'
        });

        // Queue task on connect
        client.on('connect', function() {
            console.log('connected');
            start_latitude = 1.3053947
            start_longitude = 103.8273045
            client.call('proj.tasks.getPriceEstimates', [start_latitude, start_longitude],
                function(result) {
                    console.log('result: ', result);
                    client.end();
                })
        });
    }
});

the following error occurs:

Exception while invoking method 'estimates.request' TypeError: Cannot read property 'slice' of null

Question: What is causing this error?

Github repo for reproducing problem Run localhost:3000 to trigger the problem.

1 Answer 1

0

I had the same issue and there's a mistake in the node celery documentation. The option CELERY_RESULT_BACKEND has a wrong entry.

You should set this option like this:

CELERY_RESULT_BACKEND: 'amqp://' and it should work.

Celery reads an url and slices the protocol, so if you pass amqp celery throws an exception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.