paclient
paclient copied to clipboard
client program always closing
I tried the example code and i find the client program always closing as soon as it start the app
I am getting the same issue: so the connection is immediately closed when I launched the program (FYI node version = v12.6.0) you can see in next log:
Jans-MacBook-Pro:tmp jan$ node patest.js
Connection closed
Jans-MacBook-Pro:tmp jan$
FYI: In order to connect to my pulseaudio server (also running on my macbook) I have made following change to the paclient code (see last 2 lines where I specified config and passed it as parameter to the connect method.
}).on('remove', (type, index) => {
console.log(`Removed ${type}, index #${index}`);
});
config = { "host" : "127.0.0.1", "port" : 4713 };
pa.connect(config);
The following is logged by my pulseaudio server when launching the pacient program:
I: [] client.c: Created 0 "Native client (TCP/IP client from 127.0.0.1:53838)"
E: [] protocol-native.c: protocol error, kicking client
I: [] client.c: Freed 0 "Native client (TCP/IP client from 127.0.0.1:53838)"
FYI I have activated tcp protocol by uncommenting the following in file /usr/local/Cellar/pulseaudio/13.0/etc/pulse/default.pa
### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
load-module module-native-protocol-tcp
I have not only having this issue when connecting to pulseaudio server running locally on my macbook, but I am also having this issue when trying to connect to pulseaudio server running in docker container on a raspberry pi. The following is logged (= same error message)
30.09.19 22:27:21 (+0200) pulseaudio-server E: [pulseaudio] protocol-native.c: protocol error, kicking client
So the problem is not due to pulseaudio server running on my macbook.
The protocol error logged by the pulseaudio server are triggered by the following source file (search for protocol_error)
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/blob/master/src/pulsecore/protocol-native.c
Just tested it directly on my raspberry pi (using balena application) and I am getting same problem (so in this case node.js version = v8.16.1):
node-red@ba7c427:/data$ node -v
v8.16.1
node-red@ba7c427:/data$ node patest.js
/bin/sh: 1: xprop: not found
Connection closed
node-red@ba7c427:/data$
The error logged by my pulseaudio server also running in raspberry pi docker container:
01.10.19 20:12:03 (+0200) pulseaudio-server E: [pulseaudio] protocol-native.c: protocol error, kicking client
FYI, please refer to my code below (tested in Mac environment.)
const PAClient = require("paclient");
const { readFileSync } = require("fs");
const pa = new PAClient();
const cookiePath = `${process.env.HOME}/.config/pulse/cookie`;
const cookie = Buffer.from(readFileSync(cookiePath, "binary"), "binary");
pa.connect({ host: "127.0.0.1", cookie: cookie });
Pulseaudio install guide:
- install
brew install pulseaudio
- change the
/usr/local/opt/pulseaudio/homebrew.mxcl.pulseaudio.plistfile. (insert a following line to<array>...</array>)
<string>--load=module-native-protocol-tcp</string>
- register to service (auto-run)
brew services start pulseaudio