forked-daapd
forked-daapd copied to clipboard
Feature request: keepalive / timeout in forked-daapd.conf
After a certain length of time (30 minutes or so, I think), a DAAP stream will time out. For example, pause a stream playing via Rhythmbox or Banshee. Attempt to resume playback 30 minutes later. It will fail. The only way to resume playback is to disconnect from the DAAP server and reconnect. At that point, the prior playback position has been lost.
Is it possible to add a keepalive or timeout that could be controlled via a parameter in forked-daapd.conf?
This might require a client fix instead/as well.
Could you ask Rhythmbox or Banshee if they make any attempt to tell the server they are still using the connection?
I take your point, but FWIW iTunes exhibits the same behaviour. I get the feeling Apple would be less than accommodating.
Should be fixed in forked-daapd v0.13 http://blog.technologeek.org/2011/03/12/465
Hi everyone, when playing music with iTunes 10.2.1 on a Mac, it gets disconnected from forked-daapd after 30 minutes (exactly 30 minutes from the moment iTunes is connected to the playlist, no matter if I play music or not).
I've tried with forked-daapd 0.14-1 and 0.15-1 on debian. I didn't had the problem on 0.12 and I don't remember if I have used 0.13. It seems that I don't have the problem when playing with Rythmbox 0.13.1 on Ubuntu (but I haven't checked seriously).
The only message I see in forked-daapd log file is: httpd: Connection failed; stopping streaming of file ID XXX (which is the same message I have when I skip a song in iTunes)
ldesgrange is right. I tried Forked-Daapd 0.14 on a D-Link DNS-323 with Alt-F Firmware and exactly 30 minutes after I start playing music on Itunes 10.2.1 on a Mac the connection drops, even in the middle of playing a song.
I wrote to Julien Blache (Forked-Daapd author) and he said that he is aware of the bug, but that he doesn't have time at this moment to resolve a bug that needs each time 30 minutes to reproduce.
I did a tcpdump to check if something specific was happening. Here is what I did:
- connected iTunes to forked-daapd
- started listening music
- after few minutes I put iTunes on pause, so nothing was being transferred on the network in order to have clean logs.
- 30 minutes after connecting to forked-daapd, iTunes disconnected the playlist as usual…
On the tcpdump I only see iTunes properly closing the connection: iTunes -> forked-daapd: [FIN, ACK] forked-daapd -> iTunes: [FIN, ACK] iTunes -> forked-daapd: [ACK]
I don't know, maybe while connected iTunes is waiting for some "keep alive" messages (even while already playing music from the shared library). H.T.H.
By the way I'm realizing that the problem we are discussing is a bit different from the original one (which I remember used to happen to me before I upgrade forked-daapd and get this disconnection instead), sorry for that.
I am using forked 0.14 and see this problem with iTunes on both Windows and OS X. I do not see it with Rhythmbox on ubuntu. I rarely pause so have never seen it while paused. It always happens exactly 30 mins after starting to stream in iTunes. I can stream for hours with Rhythmbox. Log shows same basic message as others have reported.
Updated to 0.16. Still has the same annoying problem. I can't believe that with so many installations on commercial NAS (and vast majority of users mostly using iTunes) there is not much of an outcry and that nobody has already solved this bug. I mean, there is surely tons of people having this annoying problem, it should be top priority.
@bobcote: afaik forked-daapd is nearly not used in commercial NAS, most of them are using mt-daapd (which didn't had this timeout issue last time I used it). I'm afraid that we are not so many using it, forked-daapd is more of a "pet project" and I don't think there are enough contributors with enough time to tackle this problem quickly (considering that you need at least 30 minutes to test each time as you said earlier). If you have any knowledge to solve this problem I'm sure everybody here will be happy ;-).
Maybe I'm wrong. I was with the impression that when last year iTunes 10 temporarily broke compatibility with mt-daapd/firelfy that QNAP and Synology had packaged Forked-Daapd as a solution, which could have lead to many people with the same problem we have here. But as I don't have those NAS (I have a D-Link DNS-323) and had this impression only by reading all the forum posts at those companies websites, I could possiibly be wrong indeed. I really thought Forked-daapd was more "serious" and was the de facto new daap server privileged by NAS makers.
I don't know, maybe you are right, but since Apple released a fixed version of iTunes 10 quite quickly I thought NAS makers didn't switched to forked-daapd, maybe if they did, at that time forked-daapd didn't had this issue either and they are still using that old version… I haven't seen people complaining about this bug on NAS (but I had only a quick look so maybe you have found some). Could be interesting to know how many NAS makers use forked-daapd by default or if they provide it as an alternative DAAP server only).
I have a QNAP NAS that I'm running this on and it came with mt-daapd. I had to replace that with forked-daapd.
I'm having this same problem, however. Exactly at the 30 minute mark iTunes drops the connection. I didn't have this problem with mt-daapd and I don't have the problem when playing through the Remote app. I found a tweet from February by someone who was looking into the problem and he found a hardcoded maximum in a file. He said he'd provide more details so hopefully that will help solve this issue.
I confirm this problem still exists in forked-daapd 0.18. iTunes 9.2.1 closes the connection exactly 30 minutes after connecting, regardless of activity. (i.e. I can be playing a song or paused during the 30 minutes, it doesn't matter) UPDATE 2011-08-24: I believe I have fixed the timeout problem. Changes can be found on this fork: https://github.com/CBGoodBuddy/forked-daapd The two commits solve a 30 minute time-out problem and also enable dynamic updating of the music listing whenever you add using files to your server. Before you had to disconnect iTunes from the server, now the new music should show up within about ten seconds. I contacted the author Julien Blache and he seemed receptive to include one or both patches for the future.
Good job CBGoodBuddy! I can't unfortunately test as I rely on the version included in Alt-F firmware for D-Link DNS-323, which is ARM based, so patches will need to be backported to the last arm compatible version.
Great work! It doesn't seem to be completely fixed though. With both patches applied iTunes happily kept playing for hours while forked-daapd was scanning my library and adding new songs every few seconds. After it finished, it eventually kicked me off and has continued to do so every +-30 minutes. (Haven't timed it, though) Tested with iTunes 10.5(b)
Well, that's frustrating. Sadly, I can't replicate the problem with iTunes 9 or 10. Can you tell if the time out is 30 minutes or 25 minutes? The new code ensures that iTunes gets some kind of activity at least every 25 minutes, but maybe that's too infrequent. (one possibility is something else is timing out, like your router)
If you have access to the code, it may be worth trying to change http_daapd.c line 64, #define DAAP_UPDATE_TIMEOUT 1500 which is a 25 minute time out expressed in seconds, to something shorter, like, #define DAAP_UPDATE_TIMEOUT 60 which guarantees activity at least every minute.
I don't know what the real iTunes does....
Rather than time the 25 minutes, I changed the line. First to 60, then to 120. On my computer (with lion and itunes 10.5) that causes a disconnect after respectively 60 and 120 seconds. On another computer I tried (snow leopard and iTunes 10.4) it's still going strong.
I don't have a lion/10.4 machine myself, but I'm going to have someone try that as well. If it's only 10.5, it might just be a (beta) bug in iTunes, though mt-daapd works fine.
OK, that's pretty weird. I'm not sure why forced activity would force-close the connection. I checked mt-daapd which uses exactly the same method (except 30 second time-outs).
I tested iTunes 9.2.1 and 10.4 on Snow Leopard. I don't have access to Lion yet.
Sounds like there is some new behavior in Lion.
Could you try a 30 second time-out just to see if that improves things? Also, if you can enable debug mode, that might give a little more information about the transactions. But, you will want to operate on a reduced music library, otherwise you will be overwhelmed with debug statements. (I usually test in debug mode with a different config file that points to a single album)
I'll try the debug thing later, but I do have some new info, tried both 30 and 20 second timeouts and they fail. Had a friend try with lion/10.4 which gave no problems, so it seems to be a 10.5 beta problem.
It would be disappointing if the new version of iTunes changes the protocol, but I guess it wouldn't be the first time.
I had this problem too; I solved it by removing some changes made in c70caad87e12357d7d912113f6a06b08d781afd1; also, I disabled autologout by setting the value for "msal" to 0.
Try this patch against head:
diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 3017b3b..b1613c9 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -633,10 +633,8 @@ daap_reply_server_info(struct evhttp_request req, struct evbuffer *evbuf, char dmap_add_int(evbuf, "apro", apro); / 12 / dmap_add_string(evbuf, "minm", name); / 8 + strlen(name) */
-#if 0 dmap_add_int(evbuf, "mstm", DAAP_SESSION_TIMEOUT); /* 12 */
- dmap_add_char(evbuf, "msal", 1); /* 9 */ -#endif
- dmap_add_char(evbuf, "msal", 0); /* 9 */
dmap_add_char(evbuf, "mslr", 1); /* 9 / dmap_add_char(evbuf, "msau", (passwd) ? 2 : 0); / 9 */
unsynchronized: That does solve the original problem, but it also disables CBGoodBuddy's awesome auto update feature which I've come to really enjoy.
Some further experiments showed iTunes ejecting when the forced update message was sent. I assumed it might have something to do with the new == old rev id on the iTunes side, so I added some hacky code to ensure it never sends a forced update with both being equal to the update method. And it seems to work. The library both auto updates and doesn't eject after either the update or the session timeout in iTunes 10.5. I couldn't find any daap documentation, so I don't know how many rules I'm breaking doing this, but it works for me.
Code I used:
Insert
if (force == 1) ++db_rev;
Before
ur->session_id, ur->revision_number, db_rev, force);
On line 857 of httpd_daap.c
Should be fixed in v0.19 http://blog.technologeek.org/2011/09/11/526
Updated my box with 0.19, iTunes was not disconnected in the last few hours. Congrats guys! Thank you very much.
It's still working on my box, auto-update is working too. @Max905 if everything is fine for you, maybe you should close this issue?
Running 0.19 vanilla, just checked out a fresh copy. iTunes 10.4.1 works like a charm (though I am not seeing autoupdates), 10.5 still disconnects every 5 minutes, regardless of the value of 'msal'. So, does not work for me.
Ditto here. It looks like the timed update response sent by update_refresh_cb() isn't making it very happy.
Two quick hacky fixes that worked for me are:
- disabling this timer altogether (or bumping DAAP_VERSION_REFRESH) -- I assume this would break updates and;
- incrementing current_rev before sending the mupd reply in update_refresh_cb.
Using #2 now; no problems yet, and updates seem to work; no long-term tests yet.
Issue #70 (https://github.com/jasonmc/forked-daapd/issues/70) argues that the number should increment whenever we see a directory rev change; this makes sense to me, as a long-term fix.
I've had this problem for a while now, and I tried applying fix #2 to the GCD version of 0.19. It didn't seem to do any live updating like CBGoodBuddy's version does though; has anyone else tried the GCD version?
You folks are right. Something has changed about iTunes 10.5: it rejects "update" notifcations that 10.4 does not. If you update the db_rev each cycle, then you will incur the penalty of iTunes re-downloading your entire music library every so often, which is not optimal and terrible for mobile use. Someone needs to understand better what iTunes needs as a response.