09 Jan 2014, 09:49
Generic-user-small

Philip O'Brien (3 posts)

Up until this point all the code has worked perfectly but when I fire up the cluster program, the workers come online fine but when I run the zmq-filer-req-loop I get no response. In the responder terminal window I get the following error

Worker 9749 is online.
Worker 9748 is online.
Worker 9750 is online.
9749 received request for: target.txt
9749 sending response

TypeError: Array.prototype.slice called on null or undefined
    at Socket.i (/Study/node/the right way/messaging/zmq-filer-rep-cluster.js:17:44)
    at Socket.EventEmitter.emit (events.js:106:17)
    at /Study/node/the right way/messaging/node_modules/zmq/lib/index.js:351:25
    at process._tickCallback (node.js:415:13)
    at process._tickFromSpinner (node.js:390:15)

I have double checked and triple checked the code and it seems fine. Any ideas?

09 Jan 2014, 10:34
Generic-user-small

Philip O'Brien (3 posts)

I just spotted the problem, the code in the book for zmq-filer-rep-cluster.js has

dealer.on('message', function() {
        let frames = Array.prototype.slice.call(null, arguments);
        router.send(frames);
});

but the null seems to be incorrect, removing it as below works

dealer.on('message', function() {
        let frames = Array.prototype.slice.call(arguments);
        router.send(frames);
});
09 Jan 2014, 15:56
Generic-user-small

Daniel Mackey (1 post)

Just hit this as well. Philip is right, removing null works.

17 Mar 2014, 00:46
Generic-user-small

Ivan johns (2 posts)

Try:

router.on('message', function() {
	let frames = Array.apply(null, arguments);
	dealer.send(frames);
});

dealer.on('message', function() {
	let frames = Array.apply(null, arguments);
	router.send(frames);
});
26 May 2014, 11:27
Avatar_pragsmall

Jim R. Wilson (60 posts)

I apologize for this typo. Originally I had Array.apply(null, arguments) and meant to switch to Array.prototype.slice.apply(arguments). Either should work, but the latter is better.

  You must be logged in to comment