Topic-icon Login to Facebook works only in site debug mode

Support Specialist
12 years 2 months ago #42171 by alzander
Alan,
Thanks for your patience and access to your server. I've definitely narrowed it down to some sort of a communications issue. I don't know what, because from just FTP access, it's not possible to determine what's causing the slow down. I'll describe my test below though.

I edited the /libraries/joomla/http/transport/curl.php file. cURL is what's used to make an outgoing request from your server using PHP. Around line 149, I added extra debugging commands around the curl_exec so that it looks like:
echo time() . " Making request<br/>";
print_r($ch);
echo "<br/>";
		$content = curl_exec($ch);
echo time() . " Request complete!<br/>";
print_r($content);
exit;
All that's doing is reporting the time before the request, the request information, performing the request, and then reporting the time after the request is done. The output looks like:
1394821998 Making request
Resource id #151
1394822062 Request complete!
HTTP/1.1 200 OK Cache-Control: no-cache, .... <a lot more data returned here>
The key point is the difference in time, which is in seconds: 64

The request being made is only to get the user's ID from Google. Subsequent requests would have to be made to get that user's profile information (email, name, etc). At 1-minute a piece, multiple requests could easily add up to the multiple-minute sign-in time you're seeing.

Taking it one step further, I printed out the cURL stats, and below is the output:

Array (
=> accounts.google.com/o/oauth2/token
[content_type] => application/json; charset=utf-8
[http_code] => 200
[header_size] => 471
[request_size] => 512
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 64.296276
[namelookup_time] => 0.015591
[connect_time] => 63.135362
[pretransfer_time] => 63.166707
[size_upload] => 354
[size_download] => 1150
[speed_download] => 17
[speed_upload] => 5
[download_content_length] => -1
[upload_content_length] => 354
[starttransfer_time] => 64.295313
[redirect_time] => 0
[certinfo] => Array ( ) [redirect_url] =>
)

It may be hard to read, but the namelookup and download time looks right. The pretransfer_time is 63 seconds (which is pretty much the whole time). I'm not sure why it's taking that long. Some searching of Google indicates that SSL connectivity issues could be the problem (you're connecting to Google securely, which is a requirement). However, there's no bullet-proof solution.

I'm not sure what's causing the drastic delay you're seeing. The curl_exec call is a raw PHP function though. It's the lowest level call we can make, and there's nothing else in between those times that Joomla or JFBConnect is doing.

With all that said, it's definitely not an issue with JFBConnect directly. There is definitely some sort of server issue that is making cURL requests (or something lower level than cURL) perform very, very slowly. I hope this helps narrow things down for you. I've gone ahead and left the 8 lines I added to the curl.php file, though commented out, so that you can uncomment them and see the result for yourself if you'd like.

Hopefully, this helps get you somewhere. I'd recommend contacting your host to help diagnose from here since, as I said, that's the lowest level call in PHP and there's nothing we could do at a higher level to speed things up.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 2 months ago #42178 by bungee
Alex, you are the king!

Your thorough analysis helped me to pin down the problem. It looks like the problem is in IPv6 routing.
I added the following line to curl.php
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

This tells curl to use IPv4. Apparently curl uses IPv6 first and there is some IPv6 routing problem somewhere. My host should be IPv6 enabled but I can check on that.

Now, Google+ connects in a second or two...

Many thanks for your time and support,
Alan
The topic has been locked.
Support Specialist
12 years 2 months ago #42179 by alzander
Ahhhmazing :) So glad to hear we could help get you going, and very happy to have that narrowed down. As noted, it was an obscure issue, so I hope the few days it took to narrow down weren't too cumbersome. We'll definitely take note and have your solution in the back of our mind the next time a nebulous "it takes too long" request comes it. Those are always the worst due to all of the variables involved from JFBConnect through to Joomla, your server and onto the social network itself.

Of course, should you need anything else, you know where to find us.

And, finally, if you haven't already, please consider leaving a rating and review for JFBConnect, or our support, on the Joomla Extension Directory. It certainly isn't required, but is very appreciated:
extensions.joomla.org/extensions/social-...ook-integration/7215

Thanks, and best of luck to you, and your site,
Alex
The topic has been locked.