# Mpc clients are slow to connect to git version of mopidy

**URL:** <https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518>\
**Category:** Misc\
**Created:** [January 10, 2015, 10:27am UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518 "2015-01-10T10:27:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Ambridge](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@Richard\_Ambridge](https://discourse.mopidy.com/u/Richard_Ambridge)\
**Post date:** [January 10, 2015, 10:27am UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/1 "2015-01-10T10:27:03Z")

</div>

If I run mopidy from apt-get released version, everything works fine.  
If I run ‘mpc next’ then immediately mopidy changes to the next track.

However I am hitting the issue of spotify pausing when there is no internet, so I installed mopidy (and mopidy-spotify and pyspotify) from git version.  
Everything is still working find, but now when I run ‘mpc next’ or select a track from any mpc client, there is a long delay (30 seconds) before mopidy changes track.

The mopidy log file shows nothing, until it shows ‘New MPD connection from’ and as soon as that is shown the track is changed.

Any idea why the client takes so long to connect?

Thanks

---

<div class="post-metadata">

**Author:** ![adamcik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/adamcik/32/5_2.png) [@adamcik](https://discourse.mopidy.com/u/adamcik)\
**Post date:** [January 12, 2015, 1:29pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/2 "2015-01-12T13:29:14Z")

</div>

Hard to say with the info you’ve posted so far. Have you looked at [https://docs.mopidy.com/en/latest/troubleshooting/](https://docs.mopidy.com/en/latest/troubleshooting/) ?

---

<div class="post-metadata">

**Author:** ![Richard\_Ambridge](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@Richard\_Ambridge](https://discourse.mopidy.com/u/Richard_Ambridge)\
**Post date:** [January 12, 2015, 1:44pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/3 "2015-01-12T13:44:13Z")

</div>

I did some more digging.  
Its only when mopidy-spotify is enabled.

Every mpd command received seems to ask all the extensions for a playlist refresh. This asks mopidy-spotify to refresh its playlists, which I have a lot in my spotify account.  
Not sure why it has to refresh playlist on every command.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 12, 2015, 2:39pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/4 "2015-01-12T14:39:35Z")

</div>

Mopidy doesn’t refresh the playlists on every MPD command, this must be your client. Which MPD client are you using?

---

<div class="post-metadata">

**Author:** ![Richard\_Ambridge](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@Richard\_Ambridge](https://discourse.mopidy.com/u/Richard_Ambridge)\
**Post date:** [January 12, 2015, 3:07pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/5 "2015-01-12T15:07:17Z")

</div>

I’m using ‘mpc’ and also python-mpd2 client,and android client… all seem to give same result.

mopidy/session.py seems to be created for every command request, which creates a new displatcher.MpdDispatcher()

mopidy/dispatcher.py **init** this init is calling self.refresh\_playlists\_mapping()

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 12, 2015, 4:34pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/6 "2015-01-12T16:34:18Z")

</div>

That code does not explicitly refresh the playlists but I think the new 2.0 version of mopidy-spotify always works with fresh data. Which is great when it comes to reflecting playlist changes you make in Spotify’s official/web client but maybe not so great in this case.

---

<div class="post-metadata">

**Author:** ![adamcik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/adamcik/32/5_2.png) [@adamcik](https://discourse.mopidy.com/u/adamcik)\
**Post date:** [January 13, 2015, 2:25pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/7 "2015-01-13T14:25:25Z")

</div>

I think we left a TODO somewhere in that code about making that mapping a global / caching it higher up. As things stand now it is indeed rather inefficient.

Opened [https://github.com/mopidy/mopidy/issues/934](https://github.com/mopidy/mopidy/issues/934) and am happy to merge a PR if someone takes has time to clean this up as I’m still stuck on other tasks 🙂

---

<div class="post-metadata">

**Author:** ![Richard\_Ambridge](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@Richard\_Ambridge](https://discourse.mopidy.com/u/Richard_Ambridge)\
**Post date:** [January 13, 2015, 2:51pm UTC](https://discourse.mopidy.com/t/mpc-clients-are-slow-to-connect-to-git-version-of-mopidy/518/8 "2015-01-13T14:51:07Z")

</div>

I have a basic ‘cache all playlist’ bit of code i have added for now.  
When I work out how, I will upload a git request to show it.

also just managed to get offline playlists to work from spotify… (this was my big goal), i’ll upload that again when I finish testing and work out how
