Sometimes, spotify playlist doesnt load

i have a python script on a pi2 running the Mopidy 2 that receives serial commands over USB. The commands are linked to spotify playlists. So every time a command comes in, I execute:

mpc clear

and after a 0.1 second delay:

mpc add spotify:user:blahblahblah
mpc play

this works most of the time, but every once in a while I get this (but it recovers after a few tries):

2016-10-15 21:24:05,235 ERROR [1017:MpdFrontend-12] pykka: Unhandled exception in MpdFrontend (urn:uuid:e8e40929-18dd-4e44-9a29                                  -b9956353fe60):
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/dist-packages/mopidy/mpd/actor.py", line 84, in on_event
    self.send_idle(_CORE_EVENTS_TO_IDLE_SUBSYSTEMS[event])
  File "/usr/lib/python2.7/dist-packages/mopidy/mpd/actor.py", line 88, in send_idle
    listener.send(session.MpdSession, subsystem)
  File "/usr/lib/python2.7/dist-packages/mopidy/listener.py", line 27, in send
    'kwargs': kwargs,
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 398, in tell
    raise ActorDeadError('%s not found' % self)
ActorDeadError: MpdSession (urn:uuid:1dc2495f-45b3-4292-bd00-3525513393f8) not found
2016-10-15 21:24:05,328 INFO [1017:MpdSession-671] mopidy.mpd.session: New MPD connection from [::1]:56278
2016-10-15 21:24:05,340 WARNING [1017:MainThread] mopidy.internal.network: Rejected connection from [::1]:56280
2016-10-15 21:24:05,460 INFO [1017:MpdSession-672] mopidy.mpd.session: New MPD connection from [::1]:56282
2016-10-15 21:24:05,557 WARNING [1017:MainThread] mopidy.internal.network: Rejected connection from [::1]:56284
2016-10-15 21:24:05,568 WARNING [1017:MainThread] mopidy.internal.network: Rejected connection from [::1]:56286
2016-10-15 21:24:05,686 WARNING [1017:MainThread] mopidy.internal.network: Rejected connection from [::1]:56288
2016-10-15 21:24:06,481 WARNING [1017:MainThread] mopidy.audio.gst: GStreamer warning: gst-stream-error-quark: No volume control found (3)

On the mopidy-spotify end it says that the playlist doesnt exist, but the link is correct and it gets it right after a few tries.

What I’ve noticed is that this failure happens randomly, but when it does, it takes a few tries to work (I have to send the serial commands 2-3 times) also other playlists work fine at the same time that one particular playlist gives the timeout error… i assume the other playlists are cached and that is why…

Could this be a connectivity issue? how can I debug this more?

Increase the debug logging level. You probably want TRACE level for libspotify loading time stuff to show up.

When using Musicbox I use an IR control to select and play a playlist. I always use mpc load then the name of the playlist so I end up with this

begin
prog = irexec
button = KEY_3
config = mpc stop; mpc clear; mpc load “Mumford and Sons”;mpc shuffle; mpc play;
end

If it’s a single word title playlist you don’t need the " "
You need to get the title exactly right including spaces.
I don’t know if it will work if adding single tracks to a playlist using mpc add
Using mpc stop as well as mpc clear seemed to work better for me.
I haven’t got round to setting it up in Mopidy yet, but can’t think it will be much different.