Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't Node set up a named pipe server in a worker in Windows?

I'm working on enabling cluster support in a project I'm working on. This question comes directly from a statement in the Nodejs docs on the cluster module:

from: https://nodejs.org/api/cluster.html#cluster_cluster

Please note that, on Windows, it is not yet possible to set up a named pipe server in a worker.

  1. What exactly does this mean?
  2. What are the implications of this?

From the docs, and other research I've done, the actual practical consequences to this limitation are not clear to me.

like image 710
Travis Webb Avatar asked Apr 17 '16 00:04

Travis Webb


1 Answers

A process can expose a named pipe as a way to communicate with other interested parties - ie. an nginx server could expose a named pipe where all incoming requests would be sent (just an idea - I am not sure if nginx can even do that).

From Node.js process (not a cluster worker, though), you could then start an http server (or even a plain TCP server, for that matter) which listens for messages sent to this named pipe:

http.createServer().listen('\\.\pipe\nginx')

Docs for the .listen() method's signature are here, specifically this part is of interest:

Start a server listening for connections on a given handle that has already been bound to a port, a UNIX domain socket, or a Windows named pipe

However, as per the warning, this functionality is not available from a cluster worker, for reasons beyond my understanding.

Here is a relevant commit in Node.js which hints at this limitation. You can find it by opening the Markdown document for cluster, look at git blame and go further into history a bit until you arrive at the commit which introduces this note.

Normal interprocess communication is not affected by this limitation, so a cluster works just the same on Win32 as it does on Unix systems.

Note: Upon further thought, that nginx example is a bit misleading since a named pipe, to my understanding, cannot be used for stateful bidirectional communication. It's just one-way, ie. source->listener. But I do hope I conveyed the general idea behind the limitation.

like image 162
Robert Rossmann Avatar answered Oct 24 '22 01:10

Robert Rossmann