how to send ipc to hs using node-ipc ?

214 views
Skip to first unread message

Brad Winter

unread,
Jan 15, 2021, 3:21:04 AM1/15/21
to Hammerspoon
Hey there,

I'm having trouble understanding what the parameter "name" - (a string acting as the message port name.) corresponds to in this node library, node-ipc

I set up a local port like this using hammerspoon, and I want to send a message from a node instance, and see the alert show.

hs.ipc.localPort('hello', function()
hs.alert.show('got ipc!');
end)


but i'm having trouble connecting.  Could anyone please tell me what I should put as the string id and path if I'm using node-ipc.connectTo, as documented here

(I'm using Catalina)
When I try with "hello" as the string id, and i leave the path as `null`, or an empty string, i get

requested connection to  hello /tmp/hello
Connecting client on Unix Socket : /tmp/hello
######
error:  { Error: connect ENOENT /tmp/hello
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'connect',
  address: '/tmp/hello' }
connection closed hello /tmp/hello Infinity tries remaining of Infinity



and when i use id = "hello" and path = "hello" i get:


requested connection to  hello hello

Connecting client on Unix Socket : hello



######

error:  { Error: connect ENOENT hello

    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)

  errno: 'ENOENT',

  code: 'ENOENT',

  syscall: 'connect',

  address: 'hello' }

connection closed hello hello Infinity tries remaining of Infinity


I've tried many other combinations, but I don't have the exact error logs anymore.  If anyone could help me point me in the right direction, that would be greatly appreciated!

Brad

asmagill

unread,
Jan 24, 2021, 1:54:21 PM1/24/21
to Hammerspoon
At present, Hammerspoon does not support communication through unix file type sockets. `hs.socket` is used for TCP and UDP sockets, and `hs.ipc` is for using Mach style ports (which I've personally only seen between Mac applications; not sure how wide spread they are outside of macOS).

There has been occasional discussion on the github issues page concerning unix sockets as well, so I'll add it to the wishlist.

--
A-Ron

Reply all
Reply to author
Forward
0 new messages