Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSSocket server loses requests when responses are sent by child process. #50

Open
StTod opened this issue Jan 17, 2017 · 0 comments
Open

Comments

@StTod
Copy link

StTod commented Jan 17, 2017

Server code:
var worker = child_process.fork('child.js');
var server = nssocket.createServer(function(socket) {
socket.data('data', function (data) {
worker.send(data.toString('utf8'), socket.socket, {keepOpen: true});
});
});

child.js
process.on('message', function(data, socket) {
send(socket, 'data', data);
});

function send(socket, event, data, callback) {
var delimiter = '::';
if (typeof event === 'string') {
event = event.split(delimiter);
}
var message = Buffer(JSON.stringify(event.concat(data)) + '\n');

socket.write(message, callback);
};

The client send 10 requests and after timeout from 1000 milliseconds send another 10 request and so on.
The first 10 request have their responses, but next lost responses.

I use nssocker v0.6.0, Node.js v6.9.4 and testing on Windows 10 with NetBeans IDE 8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant