Sunday, 30 April 2017

Using Meteor with node-celery causes error "Cannot read property 'slice' of null"

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.



via Nyxynyx

No comments:

Post a Comment