jhead / node-svmq Goto Github PK
View Code? Open in Web Editor NEWNative System V message queues in Node.js
License: MIT License
Native System V message queues in Node.js
License: MIT License
Hi,
First of all thanks for the intresting project. One missing thing I have noticed is that mtype value is not provided on data event. It would be really useful to also know what was message type.
assuming dumb sender:
'use strict'
import MessageQueue from 'svmq'
let app = {}
const APP_IPC_KEY = 31337
const fromAPP = 100
const toAPP = 200
function start() {
try {
app = new MessageQueue(APP_IPC_KEY)
app.send = (msg) => {
app.push(Buffer.from(msg), { type: toAPP })
}
let q = 0;
while(q++ < 100000)
app.send('msg N' + q)
} catch(e) {
console.log('start failed : ' + e.message)
}
}
start()
and reciever:
'use strict'
import MessageQueue from 'svmq'
let app = {}
const APP_IPC_KEY = 31337
const fromAPP = 200
const toAPP = 100
function start() {
try {
app = new MessageQueue(APP_IPC_KEY)
app.on('data', (data) => {
console.log('rcv: ' + data.toString())
})
} catch(e) {
console.log('start failed : ' + e.message)
}
}
start()
receiver prints garbage to console
When running npm install for node 12 you will get the following error:
../src/functions.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE GetMessageQueue(Nan::NAN_METHOD_ARGS_TYPE)’: ../src/functions.cc:123:43: error: no matching function for call to ‘v8::Value::Int32Value()’ key_t key = (key_t) info[0]->Int32Value(); ^ In file included from /home/ubuntu/.cache/node-gyp/12.10.0/include/node/node.h:63:0, from ../node_modules/nan/nan.h:54, from ../src/functions.cc:1: /home/ubuntu/.cache/node-gyp/12.10.0/include/node/v8.h:2582:40: note: candidate: v8::Maybe<int> v8::Value::Int32Value(v8::Local<v8::Context>) const V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
Hi, thank you for the this IPC module. I have an issue with using it. I am trying communicate between my node server and a C program which is located in the same device. I am working with ARMv7 architecture. I am just trying to send a simple message to an id using your example code in readme. I am using Nodejs v8.11.4 and dont have npm in it. Getting packages with buildroot.
So the issue is that I am getting this fatal error
# Fatal error in ../deps/v8/src/objects.cc, line 3577
# Check failed: receiver->IsJSFunction().
when I try to run this code:
var msg = svmq.msg;
var MSGMAX = svmq.MSGMAX;
var id = msg.get(1, 950);
msg.snd(id, new Buffer('Hello World!'), 1, (err) => {
if (err) throw err;
});
Is that about being compatible with versions or that I am working on a embedded device. Thanks for all!(btw I am submitting an issue for the first time so if I did something wrong please tell.)
The first 5 messages are sent without problems, but at the 6th the program completely crashes - not in the way a Node.js program normally exits with an error, but it seems to be the interpreter itself crashing:
node: malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.
Aborted
This is under Node v7.9.0 on a Raspberry Pi 3 running Raspbian GNU/Linux 8.0 (jessie).
The behavior is reproducible: it's always at the 6th message. The first five arrive correctly. I think my code is according to the instructions: at the start of the program it does
var svmq = require('svmq');
var inqueue = new svmq(55809);
var sendarray = new Uint8Array(16);
and after that, each time a message must be sent, sendarray
is populated with the right data, after which this is run:
inqueue.push(Buffer.from(sendarray), {type: 3}, (err) => {
if (err) console.log('Error: '+err);
else console.log('Command put on the message queue');
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.