Pulseaudio connection fails with snap based on core24

Hello, While my application ran fine with the snap based on core20, moving to core24 makes pulseaudio connection fail, although the audio-playback connection is set : fluidsynth: error: Failed to create PulseAudio connection, because pa_simple_new() failed with error: Connection refused I tried to set the pulseaudio connection on too, but no success. Here are some relevant parts of the snapcraft.yaml:

apps:
  redrose:
    environment:
      FONTCONFIG_PATH: $SNAP/etc/fonts
      QT_PLUGIN_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/qt6/plugins
      LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu/pulseaudio
      GS_LIB: $SNAP/usr/share/ghostscript/10.02.1/Resource/Init
      GS_FONTPATH: $SNAP/usr/share/ghostscript/10.02.1/Resource/Font
    desktop: usr/local/share/applications/redrose.desktop
    command: usr/local/bin/redrose
    plugs:
      - opengl
      - wayland
      - x11
      - desktop
      - desktop-legacy
      - home
      - audio-playback
      - pulseaudio
      - jack1
      - alsa
      - cups-control

Any help to get back audio on my application ?

You probably need to set the PULSE_SERVER environment variable, similar to this:

You are going to have a much easier time if you use the gnome extension or kde-neon extension since this will handle most of these issues for you. If you’ve got a Qt application, the kde-neon extension is probably the right choice.

Also: don’t use the pulseaudio interface: it won’t auto-connect for any new snaps. If you’re just playing sounds, audio-playback is sufficient. If you also want to record, add the audio-record interface.

Thank you, adding the correct environment variable PULSE_SERVER did the trick.

apps:
  redrose:
    environment:
      PULSE_SERVER: unix:$XDG_RUNTIME_DIR/../pulse/native
...

About the extension kde-neon or gnome: The app is compiled against Qt6 and kde-neon-6 extension is not available for core24. I may use gnome extension but I think this would add a lot of unused stuff in the generated snap, no ?

Many thanks for your help on PULSE_SERVER environment variable !