Q: None of my iDevices can read my iTunes library after an hour of availibility. When I first start iTunes I can read the library, bu ... None of my iDevices can read my iTunes library after an hour of availibility. When I first start iTunes I can read the library, but after about 30 minutes my iPad's and iPhones can no longer access the library. I see it in the shared list, but no access. more
-
All replies
-
Helpful answers
-
Jun 4, 2012 1:30 PM in response to SilverSevensby aut0maticdan,This was driving me nuts for a while, finally this weekend I decided to write a little ruby script to restart itunes if Home Sharing bugs out. I posted the details here:
https://discussions.apple.com/message/18560614#18560614
But in short, you can find the ruby here: http://djw.s3.amazonaws.com/homesharing-keepalive.rb
A quick way to download it for use, if you aren't comfortable on the command line: Launch a terminal (command-a; type terminal; hit enter). Copy/Paste the following into the terminal and hit enter:
curl http://djw.s3.amazonaws.com/homesharing-keepalive.rb > ~/Documents/homesharing-keepalive.rb && chmod +x ~/Documents/homesharing-keepalive.rb
Whenever you want to run the script, open a terminal (you can use the one you already have running from previous step) and copy/paste the following; hit enter:
~/Documents/homesharing-keepalive.rb
Closing the terminal or hitting control-c will kill the app. To delete it, copy/paste the following and hit enter:
rm -f ~/Documents/homesharing-keepalive.rb
This has been working well for me, just keep the terminal running and minimized. In theory, it should never interrupt you while you are using home sharing. This is an OSX-only solution. You can do something very similar under windows, if you have the know-how.
-
Jun 4, 2012 2:03 PM in response to aut0maticdanby cendrizzi,Well after my anouncement yesterday I hope you will all welcome me back in the fold of having this problem. I had to log out and log back in and now everything is back to normal (broken).
aut0maticdan
Very cool solution. I should have looked into this further. I figured it was still responding to the port but just timed out on the query to get stuff from the server. Either way that is a nice solution that should not need to exist .
-
Jun 4, 2012 2:08 PM in response to aut0maticdanby cendrizzi,I also noticed that you are just outputting to the screen (puts). It would be interesting to use your tool to create a log and see how often this actually happens. I guess you keep it open since you are starting it from the terminal so how often are you seeing it in a 24 hr period?
A timestamp on the restart string would also be interesting.
-
Jun 4, 2012 2:19 PM in response to cendrizziby aut0maticdan,That's correct. You could redirect the output of the script to the log:
~/Documents/homesharing-keepalive.rb > ~/Desktop/homesharing_out.txt 2>&1
Unfortuneately I was also printing successful connections to the screen in the previous version, so I don't know how many exactly, but I do know at least one was in my terminal scroll history.
I actually just made an adjustment based on something the OP said. If just playing a song wakes it up enough, maybe I don't need to restart itunes. I'm instead trying with just asking itunes to return its state:
osascript -e 'tell application "iTunes" to player state as string'
If this works, it would be a much more elegant solution. In fact, I wouldn't even need to test the port, I could just ask for its state every five seconds with a bash one-liner:
while true; do osascript -e 'tell application "iTunes" to player state as string'; sleep 5; done
That would mean itunes would never get the chance to go to sleep. I'll let you know how it goes.
-
Jun 4, 2012 2:53 PM in response to Stephen Connorby SilverSevens,Stephen: Will the Sonos system still access the library AFTER all other devices have failed.
I think you've said that it does, but I wanted to make sure.
If that's the case, then it seems the only thing that can access the library after it starts to go bad is a NON APPLE Device.
-
Jun 4, 2012 2:56 PM in response to SilverSevensby aut0maticdan,I bet Sonos uses the old school sharing that came before Home Sharing.
cendrizzi - I forgot to mention that there is a time stamp in the output. That's the #{Time.now}
-
Jun 4, 2012 3:02 PM in response to aut0maticdanby SilverSevens,I've read the script. Understand it at the Junior Achiever level
If you could get different versions for all platforms I would certainly be willing to try.
I have Win 7/64. Don't know how much of a difference it would make vs programming for say Win XP/32
But I bet what you come up with would be Golden!!
-
Jun 4, 2012 3:09 PM in response to aut0maticdanby aut0maticdan,After doing a little digging, I don't think Sonos uses iTunes sharing of any sort. It scans the files on your hard drive and shares them itself.
Unfortunately, I don't even have a windows instance to test scripts in. I'm sure with the basic idea any windows scripter could pretty easily write something up. If my current test works, its going to get a lot easier.
-
Jun 4, 2012 4:24 PM in response to SilverSevensby Stephen Connor,Will the Sonos system still access the library AFTER all other devices have failed.
To be honest, I haven't experimented that much, but will give it a go later.
Sonos uses windows file sharing (SMB). You don't have to have the Sonos App open on the host computer to access the files from remote controllers (eg iPhone).
-
Jun 4, 2012 5:14 PM in response to Stephen Connorby SilverSevens,That I can see. My windows library. He same music library, works great.
-
Jun 4, 2012 9:14 PM in response to aut0maticdanby cendrizzi,Okay it's a go on my system. Nice work.
Also I didn't notice you had that timestamp, oversite on my part.
-
Jun 5, 2012 5:41 AM in response to aut0maticdanby Davids8477,Sad to say by the script did not help me
I could not load my shared library - but could "see" it - and looking at Terminal I saw no messages.
Oddly when I stopped the script and tried to load the library again it loaded instantly.
-
Jun 5, 2012 7:27 AM in response to Davids8477by cendrizzi,Davids8477
Same thing here so far. The port is actually open, which makes sense I guess since the apple tv sees my share but just times out trying to get anything from it. Bummer
Interesting to know there is different problems with similar symptoms out there.
-
Jun 5, 2012 8:22 AM in response to cendrizziby aut0maticdan,OK, so the simplest explanation is that there is a period of time where the port is still accessible but home sharing is still not fuctioning properly.
I still don't understand why stopping the script would resolve it. For over a week, I was hitting the port once a second with no ill effects. My thinking was opening the socket regularly would keep it alive, but it didn't do the job.
Anyway, if you guys are feeling like testing something new, try copy/pasting this into a terminal:
while true; do osascript -e 'tell application "iTunes" to player state as string'; sleep 30; done
It just requests the status from itunes every 30 seconds and prints it to the terminal. Since it does not rely on testing the port, you may find more success. I haven't finished testing it yet, but it can't hurt for you to try.
-
Jun 5, 2012 8:39 AM in response to SilverSevensby MIster Volition,I tried your program last night and found the same as above.
Your script gave me a message about restarting iTunes as soon as I started it, and i could then connect to Home Sharing. After a couple of hours of idle though, the script was giving no messages about restarting iTunes, but I couldn't access it. Whilst the Apple TV was still spinning and saying connecting, I pressed CTRL-c to stop the script and the Apple TV instantely connected.
I don't know Ruby, so am just guessing... Is your script opening the port then just keeping it open? I didn't see any code to close the port, but as I said, I'm not familiar with Ruby. Stopping the script closes the port which causes iTunes to sit up and take notice, starting Home Sharing working again? Perhaps opening and closing the port every now and again will keep iTunes alive if this is the case...
I'm likely wrong though!