Web Apps Since 2004.

Is your website boring?  Kick it up a notch.  Encodable apps easily drop into your website to make it modern, fun, and interactive, with features like file uploads, user accounts, paid subscriptions, protected pages, live chat, visitor logging, mailing lists, and more.
All apps include:
• Money-back guarantee
• No monthly fees
• Free tech support
• Easy setup (we can even do it for you!)

Workaround for the "Could not find Library" Problem with the iPhone Remote App

# Filed on Aug 16, 2008 by AnthonyDiSante 9 replies

The Remote app for the iPhone is an amazing thing: it turns your iPhone into a remote control for iTunes on your PC -- which is to say, a remote control for your stereo.  But unlike the infrared remote that came with your stereo, this remote works over wifi, so while you’re out on the porch grilling up some steaks, you can take your iPhone out of your pocket and use it to play some music on the stereo inside.

But I’m having a serious problem with Remote that I can’t find much information about online: Remote connects to iTunes and works fine for a while, but then it suddenly fails to connect to iTunes, and cannot connect again until you go to the computer and close & re-open iTunes.  My computer is a Mac mini PPC G4, but from posts in the Apple forums I know that some Windows users are having this problem too.

I had been running OS X Tiger 10.4.11; I upgraded to Leopard -- first 10.5.1 then 10.5.4 -- but that didn’t fix the problem.  I rebooted the iPhone.  I uninstalled the Remote app and reinstalled it.  I tried another iPhone.  I turned off the OS X firewall.  I made sure OS X wasn’t going to sleep.  I upgraded to iPhone OS 2.0.1.  None of those things fixed the problem.

But I discovered that if I disabled & re-enabled my Mac’s network connection, that did fix the problem.  So I immediately set to work creating a way to make this happen from the iPhone, since having to actually go over to the computer defeats the purpose of having a remote.  The result is a 2-tap solution that lets you reset your Mac’s network connection from your iPhone.  Here’s how.


Note: in the following instructions, replace "username" with your own username.

Step 1 of 6: Start Apache & Enable Your Sites Folder

In your Mac’s system prefs, go to Sharing, then enable Web Sharing.  Then run this command:

sudo cp /etc/httpd/users/username.conf /etc/apache2/users/

Go into your /Users/username/Sites/ folder and create a new subfolder called "cgi-bin".  Then edit the file /etc/apache2/users/username.conf and add the following line to the end of it:

ScriptAlias /~username/cgi-bin/ "/Users/username/Sites/cgi-bin/"

Now disable & re-enable Web Sharing, or run the command "sudo apachectl restart" which does the same thing.


Step 2 of 6: Create & Name Your Network Profiles


In your Mac’s system prefs, go to Network, then name your default network location "Online", and then create a second location called "Offline" which has all the adapters disabled.

And if your Mac doesn’t already have a fixed/static IP address, then give it one (in your "Online" location).  If your automatic/dynamic IP was something like 192.168.1.100, then set its fixed IP to 192.168.1.200.


Step 3 of 6: Create CGI Script


Create the file /Users/username/Sites/cgi-bin/fix_itunes_remote.cgi and put the following into it:

#!/usr/bin/perl
exit unless $ENV{REMOTE_ADDR} =~ /^192\.168\./;
my $sentinel = "/Users/username/Public/Drop Box/fix_itunes_remote";
`touch "$sentinel"`;
`chmod a+rw "$sentinel"`;
print "Content-type: text/html\n\n";
print qq`<html>`;
print qq`<body onload="javascript:window.opener='x';window.close();">`;
print qq`</body></html>\n`;

Then run this command to make that file executable:

chmod a+x /Users/username/Sites/cgi-bin/fix_itunes_remote.cgi

Step 4 of 6: Create Shell Script


Create the file /Users/username/togglenet.sh and put the following into it:

#!/bin/bash
SENTINEL="/Users/username/Public/Drop Box/fix_itunes_remote"
for ((i=1; i<=9; i++))
do
  if [ -e "$SENTINEL" ]
  then
    echo "sentinel exists; fixing itunes remote now."
    rm -rf "$SENTINEL"
    /usr/sbin/scselect Offline
    sleep 5
    /usr/sbin/scselect Online
  else
    sleep 5
  fi
done

Then run this command to make that file executable:

chmod a+x /Users/username/togglenet.sh

Step 5 of 6: Schedule Shell Script To Run Regularly


Run the command "crontab -e" and put the following into it:

*/1 * * * * /Users/username/togglenet.sh

Step 6 of 6: Use Your iPhone to Run the Script


On your iPhone, open Safari and visit this URL to reset your Mac’s network connection:

http://192.168.1.200/~username/cgi-bin/fix_itunes_remote.cgi

...where 192.168.1.200 is the IP address of your Mac.  Note that the page will automatically close itself.

Create a bookmark for this page on your iPhone’s home screen, right next to your existing Remote app, and name the bookmark FixRemote.  That way you can just tap FixRemote and then Remote and you’re in business.

That’s It

Visiting that URL causes the CGI script to create the sentinel file; when the shell script sees the sentinel file, it resets your Mac’s network connection.

The cronjob runs the shell script once per minute, all day every day.  And the shell script sleeps for a few seconds then loops and runs again, so the frequency of checking is actually every few seconds, not just once per minute.  If it finds the sentinel file, it turns off the network and then turns it back on again, by using the scselect command to temporarily switch your network to its "Offline" profile.

Comments:

01. Sep 14, 2008 at 10:28am by broct:

Apple posted this fix

http://support.apple.com/kb/TS1741

Worked without the hassle above.

02. Sep 14, 2008 at 12:04pm by AnthonyDiSante:

I actually did see that troubleshooting page (not exactly a "fix" in the sense of a bugfix) and I tried everything on it; it did not solve the problem for me.

03. Nov 6, 2008 at 09:01pm by Ender:

Doh! I’ve been connected to a neighbors WiFi all this time. :)

04. Apr 1, 2009 at 09:20am by Dodger:

Why not just doo all the sentinel and restarting connection stuff in the Perl script?

05. Apr 2, 2009 at 09:26am by AnthonyDiSante:

Because Apache might not have permission to change the networking profile, but the logged-in user (which executes cron and BASH) does.

06. Jul 19, 2009 at 02:58pm by Jason:

I love the comment from ’broct’ above.  It appears he either didn’t read your post, or didn’t read the apple support page before he suggested it, otherwise he’d easily see that you listed trying everything that Apple said to do, in that very help page.  What a dozer....

Anyway, any clue how I can do something similar in Windows Vista?  This "Can’t find library" issue is driving me insane.

07. Jul 19, 2009 at 03:02pm by Jason:

OH, BTW - I just did a manual network disconnect/reconnect from my wireless in Windows Vista, and literally, without touching another thing, in less than 5 seconds, the "remote" app connected to the library, perfectly. 

So... it’s the same issue you had, as I had the same problem, and the same solution worked for me, eventhough we’re on different platforms.  What’s going on for us, that apparently other people aren’t experiencing?  And again... what can I do in Windows that would work like what you’ve done for your mac?

08. Jul 19, 2009 at 09:54pm by AnthonyDiSante:

About a month after I created this post, I tracked the problem down to a router issue.  Replacing my router fixed the problem.  Sorry for not updating this post sooner.  I created this thread on the Apple Forums which contains more details, but basically my router was briefly dropping my connection at regular intervals, which apparently caused issues with iTunes+RemoteApp, although other aspects of iTunes (podcasts updates, etc) had no trouble with it.

Unfortunately I’m not sure if something similar to my workaround here would work on Vista; I guess it would depend on whether there are command-line tools for toggling the network connection in Vista.

09. Feb 11, 2010 at 12:05pm by delboy:

Using mac 10.6.2 with snow leopard, after weeks of trying various things with iphone remote, sometimes connects right away other times it cannot find library.I now turn off wi-fi on phone, attempt to connect through remote, says it cant connect as not connected to wi-fi, turn on wi-fi then try remote again and it usually connects ok Dont know why

Reply to this message here:

Your name
Email (why?)
Website (if you have one)
Subject
search posts:

home | archives ]

Shopping Cart

Your cart is empty.

Client Quotes

I just installed the demo of your product and got it up and running in no time.  I searched high and low for a decent login script and thank God I found yours.
– Adrian F.
FileChucker is working great...  Clients love it.  Vendors love it.  We love it.
– Gerry W.
You've done a wonderful job with FileChucker and UserBase, and they have made a big difference to how our website runs.
– Nicholas H.
Thank you VERY much for all of your help.  You've really impressed me.  We have support agreements for other software that costs thousands of dollars / year (just for the support), and most of them aren't as helpful as you have been.
– Keith Y.
I just want to say you guys really stand alone in that you have a quality product and you provide genuine customer service.  It's sad but those qualities are seldom found separately, much less together.  Thanks again for your time and help.
– Alex S.
I looked all over trying to find a simple cgi script.  I found that FileChucker was by far the best.  If you have issues with your hosting service's php.ini max upload size then this is the way to go.  Looking forward to future enhancements.
– Bob C.
FileChucker is a great drop-in solution for file uploads, and worth every penny of its very reasonable cost.  Encodable's support is excellent to boot.
– Loren A.
Why didn't I just do this from the get-go?  So much easier.  Thanks for your work.  FileChucker makes my work easier.
– Dominic M.
The amount of customization in the program is incredible.  I was able to integrate it into my existing page layout relatively simply.  I was also able to easily customize the look/feel to match the current site.
– Jason M.
Do you know how rare it is to have a "canned" shopping cart that can easily do complex pricing options on a single item?  Basically, they don't exist!  I have looked.  Everywhere!  And the few that might even come close to CornerStore's functionality cost a fortune!
– Tashina P.
Nice script, it's saving the day on our project.
– Aaron W.
Thanks again for a great product and great support - beyond expectations.
– Greg S.
FileChucker is helping drive the backend of several high profile entertainment sites for people like Shania Twain and Dolly Parton.  We're also using it to drive backend file uploads for a multi-billion dollar banking institution.  It's a great product.  We've tried other "chucking" upload solutions with progress bars using flash and php, but nothing works as reliably as FileChucker.
– Michael W.
I just wanted to say that yours is the first product that I've tested so far that hasn't failed on handling uploads.  This is going to work for a print company, so they are handling nothing but large files and all the other solutions I've tried so far have not been reliable.  So far yours has been 100% successful in my tests.
– Kevin H.
Just one word: Fantastic.  10-minute job to plug FileChucker into my app, and it now works a treat.  It's through the hard work by people like yourselves that make my job so much easier.  Congratulations on an outstanding product... Many many thanks.
– Sean F.
Our members think your software is fantastic...  I would recommend your software and your company to anyone.  Thanks for all your help.  It has been a pleasure dealing with you.
– Tommy A.
The work, the thought and the organization you put into this app is incredible.
– Bruce C.