# Behavior changes between running as service and with the node-red command

**URL:** <https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253>\
**Category:** General\
**Created:** [5 January 2023 18:46 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253 "2023-01-05T18:46:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [5 January 2023 18:46 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/1 "2023-01-05T18:46:40Z")

</div>

Hi there,  
I have quite an issue there and I don't understand from where it could be !

In my flow, I have a slider to control the pulseaudio volume in command lines with exec node, and some .mp3 files played with play-sound nodes.  
Everything work fine when I launch node-red with the "node-red" command, but when I start it as a service, I can't control volume, and the .mp3 files won't play.

The logs before the start of the flows are the same...

I'm on raspberry pi 3b, and Node-red 3.0.2 and Node.js 19.3.0

Any idea ?

Thanks !

---

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [5 January 2023 18:51 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/2 "2023-01-05T18:51:49Z")

</div>

Here is a debug message when I try to play .mp3 file with node-red launched as a service

"High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3.  
Version 0.3.2-1 (2012/03/25). Written and copyrights by Joe Drew,  
now maintained by Nanakos Chrysostomos and others.  
Uses code from various people. See 'README' for more!  
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!  
tcgetattr(): Inappropriate ioctl for device

Directory: /home/cr1/.node-red/static/Sons  
Playing MPEG stream from file.mp3 ...  
MPEG 1.0 layer III, 192 kbit/s, 44100 Hz joint-stereo  
ALSA lib pcm.c:2660:(snd\_pcm\_open\_noupdate) Unknown PCM cards.pcm.front  
Can't find a suitable libao driver. (Is device in use?)"

I don't understand why everything works fine when I don't start node-red as a service...

---

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [5 January 2023 19:06 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/3 "2023-01-05T19:06:52Z")

</div>

Okay, first, sorry for "spamming" !

I kind of "solved" the issue, with an idea I found in another topic.  
I uncommented the line "autospawn=yes" in /etc/pulse/client.conf.

But I still don't get why it works now...

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [5 January 2023 19:55 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/4 "2023-01-05T19:55:48Z")

</div>

> [@eltigrezinno](#):
>
> Node.js 19.3.0

I am not saying that this is the reason, but noticed you are using an unstable version. Does node-red support this version? Did it work properly using v18?

---

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [5 January 2023 20:08 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/5 "2023-01-05T20:08:32Z")

</div>

Thanks for your answer !

I think it was the same because I encoutered this issue when I installed node-red with the script for raspberry pi.  
I tried to reinstall everything from zero, and I manually added nodejs, npm and node-red to see if it would be better but no !

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [5 January 2023 20:16 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/6 "2023-01-05T20:16:12Z")

</div>

I'm not sure what all the pieces are in your set-up, but if you expect Node-RED to control the volume on the local machine then running it as a service will present challenges: it's most likely not running with the same user ID and some of the system contexts are also different.

---

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [5 January 2023 20:53 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/7 "2023-01-05T20:53:02Z")

</div>

Thanks for your reply !

I see... But just play a .mp3 doesn't work either. I think the issue is from pulseaudio, you're probably right, maybe it's not the same user id and pulseaudio can't be called or something.

Unfortunately, my knowledge of raspian and node-red are really too limited to understand better haha

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 January 2023 21:20 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/8 "2023-01-05T21:20:26Z")

</div>

Most likely this is a user/group permissions issue. Check that the user running node-red from startup is in the correct group to be able to access the audio.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 January 2023 23:23 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/9 "2023-01-05T23:23:29Z")

</div>

Yes. The environment when running as a service and when running from the command line are going to be different.

---

<div class="post-metadata">

**Author:** ![eltigrezinno](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@eltigrezinno](https://discourse.nodered.org/u/eltigrezinno)\
**Post date:** [6 January 2023 12:12 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/10 "2023-01-06T12:12:08Z")

</div>

Thanks for your reply ! 🙂

I understand better now !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 January 2023 12:12 UTC](https://discourse.nodered.org/t/behavior-changes-between-running-as-service-and-with-the-node-red-command/73253/11 "2023-01-20T12:12:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
