this is my code ----
var nsq = require('nsqjs');
var r = require('rethinkdb');
var nsqvar = (process.env.NSQD_RETH || "localhost:4161").split(",");
var p = r.connect({host:'localhost', port:8080, db:'test', authKey:''});{
p.then(function(conn) {
console.log("Succesfull connection")
}).error(function(error) {
console.log("Error at connection")
})
// Event Reader functionality inside connect callback
var eventreader;
eventreader = new nsq.Reader('hello_topic', 'hello_channel', {
lookupdHTTPAddresses: nsqvar
});
eventreader.connect();
eventreader.on('message', function (msg) {
// Now we have access to the connection
r.table('sprinkle_nsq_test').insert(msg.json()).run(conn);
console.log('Received message [%s]: %s', msg.id, msg.body.toString());
msg.finish();
console.log(msg);
});
}
And from the terminal I am trying to insert
curl -d '{"id": "712", "name": "Douglas Adams""type "casdasdasomedy"}' 'http://127.0.0.1:4151/put?topic= hello_topic'
At nsq at receives the message but at nodejs program at says throw new Error("Invalid JSON in Message"); ^ Error: Invalid JSON in Message
and also at same time the message is not storing at rethinkdb.