GioF71 / librespot-docker

Use Librespot (Spotify Connect) with Docker (Alsa & PulseAudio supported)
Apache License 2.0
19 stars 1 forks source link

Connection reset by peer (os error 104) #43

Closed yanover closed 1 year ago

yanover commented 1 year ago

Hello,

I am trying to deploy this image in a Kubernetes cluster (K3s). The pod is running on a target node, which is a Raspberry Pi 3 with a HIFI-BERRY DAC+ plugged on it.

I have already tested several images but I always get the same error, it must be more related to the configuration than to the image itself.

I can connect via Spotify-connect, but after a few minutes the music stops and I get the following errors in the logs:

[2022-10-23T14:55:41Z ERROR librespot_playback::player] Unable to load audio item: MercuryError
[2022-10-23T14:55:41Z ERROR librespot_core::session] Connection reset by peer (os error 104)
[2022-10-23T14:55:41Z ERROR librespot_connect::spirc] subscription terminated
[2022-10-23T14:55:41Z WARN  librespot] Spirc shut down unexpectedly

And when I open a connection throught Spotify-connect, I very often get :

[2022-10-23T14:48:34Z WARN  librespot_playback::audio_backend::alsa] Error writing from AlsaSink buffer to PCM, trying to recover, ALSA function 'snd_pcm_writei' failed with error 'EPIPE: Broken pipe'
ALSA lib pcm.c:8545:(snd_pcm_recover) underrun occurred

I'm not sure if asound.conf is used in the image, but here's the configuration file I mount in the pod (/asound.conf):

pcm.!default {
  type hw card 0
}
ctl.!default {
  type hw card 0

And here are the environments variable provided to the container :

env:
  - name: DEVICE_NAME
    value: SPEAKER
  - name: DEVICE
    value: hw:0,0
  - name: DEVICE_TYPE
    value: speaker
  - name: FORMAT
    value: S24
  - name: BITRATE
    value: '320'
  - name: ENABLE_CACHE
    value: 'Y'
  - name: CACHE_SIZE_LIMIT
    value: 3G

I've already try to run without the cache. I suspect a PCM buffer problem but I would like your opinion ?

Thank you !

GioF71 commented 1 year ago

Hello, when you say "I have already tested several images", do you refer to my images or also other librespot images? The issue you mentioned has never occurred to me. Surely otoh I never deployed the image to a kubernetes cluster. Is the pi3 somehow under heavy cpu/memory load? I believe your configuration is correct. I generally don't change the alsa defaults, but I target my output card in the container configuration, but I don't think this can be an issue.

About this: [2022-10-23T14:55:41Z ERROR librespot_connect::spirc] subscription terminated

of course you are sure your subscription is actually not terminated?

Thank you

yanover commented 1 year ago

Mostly your image, I have try other but I choose this one because it is maintained. Anyway, I'm not sure it's really related to the image itself. It use to work for several month (It was not very stable, we were disconnected from time to time but no errors in the logs.

The host hasn't change at all in any way since those problems appear.

Now, if I restart the pod, it works for a few songs and after a while it starts to bug. The spotify connect access point disappears and I have to restart the pod if I want it to work again.

2022-10-28T21:29:37Z INFO  librespot_playback::player] Loading <Inspiring Ambience for Gaming> with Spotify URI <spotify:track:0EUScTgIUzoGj3T6d28Ty3>
[2022-10-28T21:29:39Z INFO  librespot_playback::player] <Inspiring Ambience for Gaming> (137183 ms) loaded
[2022-10-28T21:32:24Z ERROR librespot_playback::player] Unable to load audio item: MercuryError
[2022-10-28T21:32:24Z ERROR librespot_core::session] Connection reset by peer (os error 104)
[2022-10-28T21:32:24Z ERROR librespot_connect::spirc] Cannot flush spirc event sender.
[2022-10-28T21:32:24Z WARN  librespot_connect::spirc] Cannot flush spirc event sender.
[2022-10-28T21:32:24Z WARN  librespot_playback::player] Skipping to next track, unable to load track <SpotifyId { id: 237286849939745773777394934953587868235, audio_type: Track }>: ()
[2022-10-28T21:32:24Z WARN  librespot] Spirc shut down unexpectedly
[2022-10-28T21:32:24Z WARN  librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:4070
[2022-10-28T21:32:24Z WARN  librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:443
[2022-10-28T21:32:24Z WARN  librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:80
[2022-10-28T21:32:24Z INFO  librespot_core::session] Connecting to AP "ap-gae2.spotify.com:4070"
[2022-10-28T21:32:26Z INFO  librespot_core::session] Authenticated as "31ha3znra77vzf5xmna5x6fr2bh4" !
[2022-10-28T21:32:26Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)

Thank you !

GioF71 commented 1 year ago

I see, but it did not happen to me. Also my subscription is currently terminated, I will probably renew it in a few weeks.

Have you tried with librespot alone, without docker/k3s, on the same hardware? You probably already know how to do that, but anyway, just in case: librespot You might have to install cargo before installing librespot: cargo

It would be interesting to see if this happens on the binary without containerization,

Cheers

GioF71 commented 1 year ago

Also, would it be possible to try in a simple docker environment instead of k3s, just to eliminate a few variables? Thanks

GioF71 commented 1 year ago

Hello, I am closing this for now. Feel free to re-open or create a new ticket is the issue is not solved.