How-to Fix WP HTTP Error: name lookup timed out

This blog and the Snowferno site both run WordPress on separate but identically-equipped Lunarpages servers. When I went to apply today’s WordPress 2.8.4 upgrade, one install was giving me “WP HTTP Error: name lookup timed out” messages and no upgrade button, while the other worked just fine. There are some workarounds detailed on the WordPress support site, but I wasn’t happy having to disable cURL on one host and not the other. It had to be something else…

The problem for me was caused by lines 1276-1277 of the wp_Http_Curl request() method in wp-includes/http.php:

curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] );
curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );

I commented those lines out and threw in a line of debug code on line 1325 (after the curl_exec call)

print_r(curl_getinfo($handle));

and tested the cURL transport using Core Control. I found that my requests were simply taking longer than the timeout provided. I don’t know quite why, except to guess that one server must be just more swamped than the other.

I fixed it by building myself a little plugin that adds an action for the 'http_api_curl' action called on line 1315.

After enabling this fix, WP showed the 2.8.4 upgrade button on the Dashboard page, but the WordPress Development Blog and Plugins RSS feed boxes still showed timeout errors. So, I looked further and found a filter that catches and can modify $r['timeout'] in the wp_Http request() method on line 237.

Here is my barebones plugin code, which overrides all timeouts to a massive 15 seconds:

//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
	$r['timeout'] = 15;
	return $r;
}

add_action('http_api_curl', 'bal_http_api_curl', 100, 1);
function bal_http_api_curl($handle) //called on line 1315
{
	curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
	curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}

I recommend you make sure this does not cause any other issues for your WP install. If you know how to make this code into a plugin, then you are capable enuf to be responsible for any adverse fallout. 🙂 I only know this solved my immediate problem while still maintaining cURL functionality.

New site design launched at benbritten.com

Our pal and Snowferno collaborator, Ben Britten Smith, asked me a while (weeks?) ago to port his website and blog over to a 100% WordPress-powered site. After we submitted the Snowferno build to Apple, I got working on it, and here’s how it turned out:

benbritten.com homepage

new benbritten.com homepage

Ben had previously rolled his own mini-CMS, but had started wanting to unify his site content with his K2-themed blog. Ben’s site is also his portfolio site, so I wouldn’t have normally gone 100% WordPress. But after becoming familiar with the family of WooThemes premium themes for the Snowferno site, we selected the VibrantCMS theme and I went about the business of porting his content over to the new site. Through a little bit of backend category magic, many of the WooThemes manage to separate the blogginess of WordPress Posts from the CMSness of Pages. I’m sure a whole host of plugins would have done something equivalent, but this way it came all built-in to the theme. We also weren’t quite ready to learn a whole new platform like Drupal or Joomla just for a cosmetic upgrade.

And who’d have thought I’d ever buy a theme for WordPress when there are so many good free ones out there. But the thing I do love is the profit motivation keeping WooThemes well-maintained. Just today I found and applied a big update to the VibrantCMS backend. After you consider how many hours they saved me just by including a new IE 8 stylesheet, you can hardly justify not using premium themes.

I needed to map his old URLs, so .htaccess handles routing the old blog permalinks from http://benbritten.com/blog/ up a level to the root http://benbritten.com/. Then since his old CMS used a querystring scheme similar to WordPress, I had to use the Redirection plugin to catch those incoming links.

Snowferno.com is live

The website for our upcoming iPhone game collaboration with Ben Britten is now live. Check out snowferno.com for details, screenshots, development blog, and hear some clips from the soundtrack.

You’ve heard the saying — but where did it all begin?
Who was that snowball, and what exactly was it doing in Hell?

Snowferno is a new take on the classic marble roller game – set (very) loosely in the 9 rings of Dante’s Inferno, with 20 puzzle challenges & starring the original “Snowball-in-Hell”.

Programming and artwork are by Ben. Mike and I are writing the music and designing (most of) the levels. We are nearing a beta release and hope to hit the iTunes App Store early July.

Reminder: Set your blogs ahead too

About the only thing left in my world that doesn’t adjust itself to Daylight Savings Time are my WordPress installations. So, along with that wall clock and old VCR, don’t forget to set your blogs ahead one hour, too.

In your control panel, go to:
Settings > General

…and choose a timezone value that is +1 your current setting. (i.e. Eastern Standard Time is “UTC -5”, so for the summer you need to set it to “UTC -4”).

A few fixes for Podcasting plugin feed validation errors

I just got a Feedburner warning that my podcast feed was invalid. I was also getting quite a few Feed Validator errors, but nothing I could fix in Podcasting’s settings or trace to bugs in the plugin code. Evidently, some versions ago, Podcasting stored a few odd values in my WP database that had to be manually corrected. Here’s how I fixed them.

Check your feed’s <itunes:name> and <itunes:email> values and make sure they are not reversed. Mine were. So just find your “pod_itunes_ownername” and “pod_itunes_owneremail” values in your “wp_postmeta” table and edit them.

SELECT * 
FROM  `wp_options` 
WHERE  `option_name` LIKE 'pod_itunes_owner%'

Second, a bunch of my posts’ “explicit” values were stored as “default” instead of the correct “” (empty string). iTunes only allows “no”, “yes”, and “clean” for <itunes:explicit>, and Podcasting didn’t translate “default” into anything, so you gotta fixup these posts:

SELECT * FROM `wp_postmeta`
WHERE
     `meta_key` = 'enclosure' and
     `meta_value` like '%s:8:"explicit";s:7:"default";%'

… and after making sure your database is backed up and all that, just run this query to update them:

UPDATE `wp_postmeta`
SET `meta_value` = replace(`meta_value`, 's:8:"explicit";s:7:"default";', 's:8:"explicit";s:0:"";')
WHERE
     `meta_key` = 'enclosure' and
     `meta_value` like '%s:8:"explicit";s:7:"default";%'

Hello World from my iPhone

This is my first post using the new WordPress iPhone app on my new phone.

We got in line at 7:45a at the Soho Apple Store. We had our vouchers by about 9:00a. It took another 2.5 hours to get phones. The actual activation took 4 minutes per phone.

Below is the last photo taken by my Razr:

photo

***UPDATE***
Our friend who left the line around 9:00a with his voucher returned at 4pm and had his phone by 4:10. 🙁