Showing posts with label zeromq. Show all posts
Showing posts with label zeromq. Show all posts

Tuesday, March 3, 2020

How to fix ZEROMQ ipc issue in windows 10 for node.js development?

i have a line to connect to the DEALER socket.

const responder=zmq.socket('rep').connect('ipc://filer.dealer.ipc');

when i run the app. the error comes up immediately

 this._zmq.connect(addr);
            ^
Error: Protocol not supported
    at exports.Socket.Socket.connect (C:\node\microservices\node_modules\zeromq\lib\index.js:519:13)
    at Object.<anonymous> (C:\node\microservices\zmq-filer-rep-cluster.js:26:39)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

obviously IPC is for Linux and Unix in process communication. windows did support this kind of communication too. however windows use INPROC instead.

after i changed my code as following, the error had been fixed and running

const responder=zmq.socket('rep').connect('inproc://filer.dealer.ipc');


how to fix "TypeError: zmq.socket is not a function" with Node.js in Windows 10?

i just try to use ZEROMQ for a simple publish/subscribe Message passing app.

when i run the app with Node myApp.js. the app thrown an exception

C:\node\microservices\zmq-watch-pub.js:6
const publisher=zmq.socket('pub');     

TypeError: zmq.socket is not a function
    at Object.<anonymous> (C:\node\microservices\zmq-watch-pub.js:6:21)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47


 I am running in the windows 10 environment and i install zeromq@4.3.2

 "dependencies": {
    "zeromq""4.3.2"
  }

 i already encounter an error during the npm install  zeromq@4.3.2, i have to install verison 5 to avoid the error   npm install  zeromq@5

here is my current zeromq package

 "dependencies": {
    "zeromq""^5.2.0"
  }

Now i can launch the app and start monitoring the file change.

PS C:\node\microservices> node zmq-watch-pub.js target.txt
Listening for zmq subscribers....