Reputation: 2662
I'm using drupal 7 with the Media Youtube module. The module calls the youtube oEmbed API.
This is an example of url the module will call: http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=YZqqD1Rv5BI
On my desktop, this returns a json file, all fine. However on my website's server, I get a 503 Service unavailable error. Actually I frst get a 302 not found, saying the url has moved, then a 503 error:
Here is what I get when I do a wget manually:
wget http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=YZqqD1Rv5BI
--2014-09-28 21:55:49-- http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=YZqqD1Rv5BI
Resolving www.youtube.com (www.youtube.com)... 2a00:1450:4007:808::1004, 173.194.40.131, 173.194.40.132, ...
Connecting to www.youtube.com (www.youtube.com)|2a00:1450:4007:808::1004|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://ipv6.google.com/sorry/IndexRedirect?continue=http://www.youtube.com/oembed%3Furl%3Dhttps://www.youtube.com/watch%3Fv%3DYZqqD1Rv5BI [following]
--2014-09-28 21:55:49-- http://ipv6.google.com/sorry/IndexRedirect?continue=http://www.youtube.com/oembed%3Furl%3Dhttps://www.youtube.com/watch%3Fv%3DYZqqD1Rv5BI
Resolving ipv6.google.com (ipv6.google.com)... 2a00:1450:4007:808::1008
Connecting to ipv6.google.com (ipv6.google.com)|2a00:1450:4007:808::1008|:80... connected.
HTTP request sent, awaiting response... 503 Service Unavailable
2014-09-28 21:55:49 ERROR 503: Service Unavailable.
Any help would be much much appreciated. Thanks in advance
Upvotes: 0
Views: 757
Reputation: 9459
I found a way to force IPv4 DNS resolving in PHP:
$url = 'http://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZVSd5aSXlQ0';
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$json = curl_exec($c);
$status = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
This solution is actually working for me.
Upvotes: 0
Reputation: 66
I met the same error, but the issue is not with the module, unfortunately (I would be able to fix it and commit a patch for the module mantainer).
As you already tested, even a simple wget gives the same issue and it comes from the fact that it uses IPv6. If you can force requests to youtube to be handled through IPv4 the problem will be solved. But this is just a work-around, not a real fix.
Upvotes: 1