Random use of fsock

Discussion in 'PHP' started by guruguy, Jan 17, 2008.

  1. #1
    I have a problem in that I have a script that works fine on my local development server, in that it opens 99% of fsock connections without any problems. However when I upload it to my website, only around 15% of the connections are opened successfully. Does anyone have any ideas on what could cause?
     
    guruguy, Jan 17, 2008 IP
  2. neanton

    neanton Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe you should set longer timeout for connection?

    $timeout = 30; //in seconds
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, $timeout);
     
    neanton, Jan 17, 2008 IP
  3. guruguy

    guruguy Active Member

    Messages:
    553
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #3
    After I posted this I just realised that I forgot to check errstr. It was a timeout issue, however the 9 second timrout works fine on my localhost but not on my remote hosting. I think I'll use your suggestion of a longer timeout period. Maybe the issue is that my computer is faster than my hosting, making my hosting timeout and not my local computer?
     
    guruguy, Jan 17, 2008 IP
  4. guruguy

    guruguy Active Member

    Messages:
    553
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #4
    I tried setting a longer connection timeout but to no avail. This is really bugging me as I can't work out whats wrong. Does anyone know of what server settings would cause it to timeout? I just wish it would all work as if it were on my local server:(

    Now it is not connecting at all and will timeout every connection. I think I'll just try some other hosting
     
    guruguy, Jan 17, 2008 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Slow DNS lookups maybe? Unfortunately on shared hosting that's probably out of your hands.
     
    SmallPotatoes, Jan 17, 2008 IP
  6. guruguy

    guruguy Active Member

    Messages:
    553
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #6
    I am now convinced it is a firewall issue. I checked the scripts logs and it is only letting connections through on port 80, and even then a few of them are being blocked. If this is the problem and I get a VPS, would I be able to fix it?
     
    guruguy, Jan 17, 2008 IP
  7. guruguy

    guruguy Active Member

    Messages:
    553
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Just finished talking to my hosting support, and they are convinced that it is a script problem. This is driving me insane!
     
    guruguy, Jan 18, 2008 IP