Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: keepalive / timeout in forked-daapd.conf #19

Open
Max905 opened this issue Oct 7, 2010 · 108 comments
Open

Feature request: keepalive / timeout in forked-daapd.conf #19

Max905 opened this issue Oct 7, 2010 · 108 comments

Comments

@Max905
Copy link

Max905 commented Oct 7, 2010

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?

@peterjc
Copy link
Contributor

peterjc commented Oct 7, 2010

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?

@Max905
Copy link
Author

Max905 commented Oct 7, 2010

I take your point, but FWIW iTunes exhibits the same behaviour. I get the feeling Apple would be less than accommodating.

@peterjc
Copy link
Contributor

peterjc commented Mar 12, 2011

Should be fixed in forked-daapd v0.13
http://blog.technologeek.org/2011/03/12/465

@ldesgrange
Copy link

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)

@bobcote
Copy link

bobcote commented Apr 15, 2011

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.

@bobcote
Copy link

bobcote commented Apr 21, 2011

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.

@ldesgrange
Copy link

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.

@vof
Copy link

vof commented Jun 14, 2011

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.

@bobcote
Copy link

bobcote commented Jun 15, 2011

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.

@ldesgrange
Copy link

@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 ;-).

@bobcote
Copy link

bobcote commented Jun 16, 2011

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.

@ldesgrange
Copy link

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).

@iamdb
Copy link

iamdb commented Jun 22, 2011

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.

@CraigMarkwardt
Copy link

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.

@bobcote
Copy link

bobcote commented Aug 24, 2011

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.

@kazdegroot
Copy link

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)

@CraigMarkwardt
Copy link

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....

@kazdegroot
Copy link

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.

@CraigMarkwardt
Copy link

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)

@kazdegroot
Copy link

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.

@CraigMarkwardt
Copy link

It would be disappointing if the new version of iTunes changes the protocol, but I guess it wouldn't be the first time.

@unsynchronized
Copy link

I had this problem too; I solved it by removing some changes made in c70caad; 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 */

@kazdegroot
Copy link

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

@peterjc
Copy link
Contributor

peterjc commented Sep 12, 2011

Should be fixed in v0.19
http://blog.technologeek.org/2011/09/11/526

@ldesgrange
Copy link

Updated my box with 0.19, iTunes was not disconnected in the last few hours. Congrats guys! Thank you very much.

@ldesgrange
Copy link

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?

@freultwah
Copy link
Contributor

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.

@unsynchronized
Copy link

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:

  1. disabling this timer altogether (or bumping DAAP_VERSION_REFRESH) -- I assume this would break updates and;
  2. 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 (#70) argues that the number should increment whenever we see a directory rev change; this makes sense to me, as a long-term fix.

@kazdegroot
Copy link

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?

@CraigMarkwardt
Copy link

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.

@CraigMarkwardt
Copy link

@lpar: strange, register_ffmpeg_evbuffer_url_protocol is part of the distribution, in src/ffmpeg_url_evbuffer.c. It shouldn't have flagged as a linking error unless you also had a compilation error.

@pcace: in August I filed a patch to do automatic updating, but the maintainer did not accept it. From what I can tell, neither of the new releases from September (0.19 nor 0.19gcd) has the capability to do automatic updating, so I'm kind of surprised that you were enjoying it. The easiest workaround is to disconnect and reconnect to your iTunes server. New library additions should appear then.

@pcace
Copy link

pcace commented Jan 7, 2012

@CBGoodBuddy: i know! I used your patch to have automatic updating enabled....
So again my question: do i have any chance to have this again?
Thanks,
Pcace

@lpar
Copy link

lpar commented Jan 9, 2012

From the configure script, it looks like the code switches from using ffmpeg for evbuffers to using libavformat if libavformat is new enough. Unfortunately this isn't working properly, and src/ffmpeg_url_evbuffer.c isn't getting compiled and linked in if libavformat's major version is < 53.

I tested by downloading and compiling libav 0.7, and with that, the build process worked fine.

@BernardV
Copy link

@CBGoodBuddy This fix works! Thanks alot!

If you want to have a test environment to test gcd etc I can provide you with a VM to do so, I've compiled it on that VM. You can even listen to the server if you use openvpn (it's configured to send broadcasts).

Thanks!

Bernard

@CraigMarkwardt
Copy link

@BernardV thanks for your offer, that's very kind and I appreciate it.

Unfortunately one of my stumbling blocks is that the new "GCD" version is actually written in a new dialect of the C programming language and I don't quite understand how it works. It's all very cutting edge, but unfortunately I have a masters degree in keepin' it old style. That, plus my real life is intruding for a while. I'll keep your kind offer in mind.

@BernardV
Copy link

Would there be interest in a virtualbox image with both the latest git version compiled and the iTunes fix version compiled?
I can make and host such an image on the latest debian stable (I think :) I now have a mix of testing/stable).

@markgsd
Copy link

markgsd commented Jan 16, 2012

Just FYI - for Ubuntu 11.10 users, all you have to do is download the Ubuntu source package, replace src/httpd_daap.c with the @CBGoodBuddy 's patched version of the file, and do the package rebuild. A good how-to for this is http://www.cyberciti.biz/faq/rebuilding-ubuntu-debian-linux-binary-package/

@faz
Copy link

faz commented Jan 23, 2012

@CBGoodBuddy @markgsd
Thanks guys, just compiled a pkg for Ubuntu 11.10 - worked flawlessly!

@kekiefer
Copy link

Craig, great work on this fix. For anyone who's interested, I ported the changes to the GCD version, and it seems to be working for me. Any feedback is appreciated!

kekiefer@77dc0fd

@CraigMarkwardt
Copy link

@kekiefer well done! Be sure to forward your patch information to Julien Blache so that (hopefully!) he can put it in the next release.

@pcace
Copy link

pcace commented Feb 6, 2012

Hmm again i do not understand so well what im doing to install this patch...
i did:
git clone https://github.com/jasonmc/forked-daapd.git
then downloaded this file:
https://raw.github.com/kekiefer/forked-daapd/77dc0fd2f466a02b86582ed2c5f97ea6e444f2ac/src/httpd_daap.c
and copied it to the src folder.
Then compiled forked-daapd. When using it, i cannot skip in tracks, and there is no length of tracks. What is wrong there?

Thanks,

Pcace

EDIT: i also tried to clone https://github.com/kekiefer/forked-daapd.git and make this: the result is a forked-daapd version where i cannot skip in tracks...

@pcace
Copy link

pcace commented Feb 17, 2012

Hmm i still cannot get the GCD to work properly,

can anyone again please help out ;) ?

When i compile the kekiefer version, there is no possiblility to skip in tracks...

Ideas?

Pcace

@kekiefer
Copy link

Thanks for the feedback, @pcace, sounds like I may have missed something.

Can someone confirm if track scrubbing works in @CBGoodBuddy's fix?

@pcace
Copy link

pcace commented Mar 1, 2012

yes, in CBGoodBuddy's fix it works perfectly!

any news?

Pcace

@pcace
Copy link

pcace commented Mar 6, 2012

Is it working at your machine? Whats wrong then there? is it working somewhere else?

@rdahlin
Copy link

rdahlin commented Mar 8, 2012

Please can someone make a .dpkg I can't compile this.. My Debian installation just xxx with me so I just beg for a dpkg to install with instead...

@lpar
Copy link

lpar commented Mar 8, 2012

http://ath0.com/forked_daapd-2_amd64.deb

6fff33ec0b756fa50fdf321949f7abb3 forked_daapd-2_amd64.deb

Note that this was made using checkinstall and I think it's missing the /etc/init.d script.

@pcace
Copy link

pcace commented Mar 8, 2012

Any chance to have this *.deb for a 32 bit system?
Thanks!!!

@lpar
Copy link

lpar commented Mar 9, 2012

Not from me, unless there's some configuration option I'm unfamiliar with. My Debian system is pure 64 bit. Sorry.

@pcace
Copy link

pcace commented Mar 9, 2012

Hmm ok no problem, but can you tell me which version this is exactly?
Has it the fixes from @kekiefer also? - so is it the 0.19GCD with the ability to skip in tracks?

Thanks

@lpar
Copy link

lpar commented Mar 9, 2012

commit f7d7dfc of branch nongcd of http://anonscm.debian.org/git/users/jblache/forked-daapd.git
patched as described by @elwertk above.

And a quick test reveals that skipping in tracks works for me.

@ghost
Copy link

ghost commented Mar 18, 2012

Hi all,
I've tried to compile the Ubuntu 11.10 source file as @markgsd said and now I can hear my music with Apple iTunes 10.6 for more than 5 minutes! Thanks @CBGoodBuddy for your nice work!

P.S.
I'll post ASAP a link for my home-build .deb package (64bit version, of course) in my personal Website, so that people will not need to install the development tools... stay tuned!

UPDATE (24/03/2012 23:51):
Hi,
I've compiled the package for both platforms (32bit and 64bit) with the @CBGoodBuddy patch. These are the links:

http://www.gieffe.name/download/forked-daapd_0.19-1ubuntu1_i386.deb
http://www.gieffe.name/download/forked-daapd_0.19-1ubuntu1_amd64.deb

@pcace
Copy link

pcace commented May 2, 2012

Hey, this is really wonderfull!
But: Has somebody a working 0.19GCD version with these Patches installed?

is there any chance that someone could compile a 0.19 GCD version of forked-daapd?

Thanks,

Pcace

@lpar
Copy link

lpar commented May 2, 2012

Yeah, my build dies after a few minutes, so I guess I'm missing a patch. A current working commit reference would be appreciated.

@MacLeodMike
Copy link

Here's a build for debian testing: http://www.mmacleod.ca/files/forked-daapd_0.19gcd-2_amd64.deb

And also what I did to make it work: http://www.mmacleod.ca/blog/2012/05/patching-forked-daapd-so-it-actually-works/

Now if only forked-daapd wouldn't disappear as soon as I enable IPv6 on my workstation...

@pcace
Copy link

pcace commented May 16, 2012

And can you skip in tracks?
Is auto database updating working?

Thanks,
Pcace

@MacLeodMike
Copy link

Huh, I cannot skip in tracks. Dunno about auto updating. All I can say with certainty is that it doesn't disconnect after 5 minuters, which is more than I had before.

@ghost
Copy link

ghost commented May 27, 2012

Just thought i'd comment and say that using a Raspberry Pi, elwertk's instructions at #19 (comment) fixed the timeout problem. I have ended up with a rather large installed package list and to be honest i'm not sure why my most recent try worked when my previous ones didn't but in the end I got there. I think I am able to skip songs and am unsure about whether it is auto-updating but it will stay connected.

Thanks to all of you for working hard to get this working! And particular thanks to elwertk and CBGoodBuddy! :)
Mike

@rishighan
Copy link

I had the 5 minute timeout issue myself; running Ubuntu 11.10 Server.
After following everything mentioned in #19 (comment) to the letter, iTunes still refused to connect.

Then I removed libevent-2.0.5 and replaced it with libevent-1.4-2 (libevent-core, libevent-dev, libevent-extra), I had to download the .debs from an older version of Ubuntu. This instantly broke transmission-daemon. I use Deluge now.

Then I built against the older libevent and it worked.
I think it bears repeating how building against libevent-1.4-2 will save you a lot of grief.

Thanks CBGoodBuddy for your patch!

@pcace
Copy link

pcace commented Apr 13, 2013

Hey, i solved the 5 min bug, thanks to @CBGoodBuddy BUT i still cannot skip in every track: only tracks converted with VBR are able to skip... in Mp3s with CBR i cannot skip.

Has anyone an idea how to solve that?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests