Seneca-mesh CL MISSING

284 views Asked by At

Anyone have experinace with seneca?

I have problem when I try to inclue mesh...

This is hapi route:

server.route({
        method: 'GET',
        path: '/api/ping',
        handler: function (req, reply) {

            server.seneca// load the mesh plugin
                .use('mesh')

                // send a message out into the network
                // the network will know where to send format:hex messages
                .act('foo:1,v:2', (err: any, out: any) => {
                    console.log(err)
                    // prints #FF0000
                    reply(null, out)
                })

        }
    })

And this is my service:

require('seneca')({
})
  //.use('zipkin-tracer', {sampling:1})
  .use('entity')
  .use('ping-logic')

  .ready(function(){
    console.log(this.id)
  })

logic:

module.exports = function post(options) {
  var seneca = this

  seneca// provide an action for the format:hex pattern
  .add( 'foo:1', function (msg, done) {
    done( null, {x:1,v:100+msg.v} )
  })
  .use('mesh', { auto:true, pin:'foo:1' })
}

I get error

CL MISSING { foo: 1, v: 2 }

Anyone know what is porblem?

1

There are 1 answers

1
Adam On

I have bumped into this, too. There were two things I had to do:

  1. Use the master branch of seneca-mesh plugin. Unfortunately the published v0.10.0 on NPM is old (2017 March 7), and does not work with seneca v3.4.x
  2. Add seneca.ready(function ()) in your hapi route like this:

    server.route({
        method: 'GET',
        path: '/api/ping',
        handler: function (req, reply) {
    
        server.seneca// load the mesh plugin
            .use('mesh')
            .ready(function () {         
                // send a message out into the network
                // the network will know where to send format:hex messages
                this.act('foo:1,v:2', (err: any, out: any) => {
                    console.log(err)
                    // prints #FF0000
                    reply(null, out)
                })
            })             
        }
    })
    

Also check this related github issue in which I asked the main contributor if there is a plan to have a new fixed version soon on NPM: https://github.com/senecajs/seneca-mesh/issues/90

Hope this helps