PHP fsockopen() error

7 posts by 3 authors in: Forums > CMS Builder
Last Post: July 1, 2014   (RSS)

By Toledoh - June 25, 2014

Hey Guys,

I'm trying to install CMSB on a new server, but get he following error

Error: PHP fsockopen() and/or network connectivity disabled!
Test connection to www.google.com return error #110 - Connection timed out

Please ask your server administrator to enable network connectivity for PHP.

I only have FTP access, no control panel, so everything has to go through their tech support.  The last email back from them said:

From what I can see there is nothing stopping the connection on our end. I wrote a test script which attempts to open a connection to google.com and this timed out. I then modified this to connect to infinite.net.au and it connected fine, so i tried a few IPs outside of our network to make sure that it does work with traffic leaving our network, and these connections also worked without issue. The only way I can get it to fail is to use google.com as the connection target. Unfortunately there is nothing we can do to change this behavior. If you're able to change where the CMS is trying to do its tests to, then you may have more luck using a different host name. 

The server is running 5.4.28.

I've also tried the test file from http://www.interactivetools.com/forum/forum-posts.php?postNum=2201380#post2201380 and that works fine.

Any thoughts?

Any ideas?

Cheers,

Tim (toledoh.com.au)

By Steve99 - June 26, 2014

Hey Tim,

If your install is hosted in a shared environment, the server IP may be blocked by Google for email abuse or some such.

Given that the server tech had timeouts connecting to Google, and it worked with other web servers, I'd think that to be the cause - however, there could be other causes. If the server tech ran his test script on the shared hosting account, that would further back up my thought of the IP being blacklisted by Google. It could also be the web hosts network IP's being blocked for abusive traffic going to Google.

You can modify that file in CMSB temporarily to connect to other hosts for some self testing.

Hope this helps.

Cheers,
Steve

By Dave - June 26, 2014

Hi Tim,

It could be an isolated anomaly or it could be indicative of larger problems with the hosts network.

If you're rushed, you can just comment out that line in /lib/init.php by adding // like this

//  _init_displaySocketErrors();

Or if you have some time to investigate further, I'd try changing the line in /lib/init.php to try other hosts: 

$handle = @fsockopen("tcp://www.google.com", 80, $errno, $errstr, 5);

And try some other hosts such as:  google.com (no www), www.googleapis.com, (used by the wysiwyg spellchecker),  yahoo.com, facebook.com

And try the IP for google.com, which for me is 173.194.33.113 as returned by ping: 

C:\Users\Dave>ping www.google.com

Pinging www.google.com [173.194.33.113] with 32 bytes of data:
Reply from 173.194.33.113: bytes=32 time=14ms TTL=56

Or use this PHP script to see what IP your web host thinks google is using: 

<?php
  header("Content-type: text/plain");
  echo `ping -c 3 www.google.com`;
  exit;
?>

Worst case you'll just have some issues using plugins or features that require internet access, like the wysiwyg spell checker or createPDF.  Or maybe it's just google they can't connect to.  That would be odd, though.  And to confirm, if your last post you meant to say the test script couldn't connect to www.google.com either as well right?  We'd want to look into it if one script could connect and another couldn't.

Hope that helps, let me know if you find out anything interesting.

Dave Edis - Senior Developer
interactivetools.com

By Toledoh - June 26, 2014

Hey Dave. I'm on the road, so will try your tests later today. My post was correct, I get an error on install, but the test file works fine. 

Cheers,

Tim (toledoh.com.au)

By Dave - June 26, 2014

Hi Tim, 

It's odd that one could connect and the other couldn't.  Feel free to email over CMS/FTP details and steps to reproduce to dave@interactivetools.com and I can take a look if you like.  Note: Email, don't post login details to the forum.

Dave Edis - Senior Developer
interactivetools.com

By Dave - July 1, 2014

Hi All, 

For anyone else with a similar issue we've tracked it down to a configuration issue with the host.  The particular issue was that IPv6 was enabled so requests to internet servers were getting IPv6 addresses instead of IPv4 but the IPv6 traffic was being blocked at the firewall or otherwise not getting outside the network.

I've added some code to the next release that tries to connect to both google.com and google's IPv4 IP address to detect when IPv6 configuration issues are preventing things from working.

Cheers!

Dave Edis - Senior Developer
interactivetools.com