Jump to content

Recommended Posts

Hi everybody!

 

I am not sure if my problem is configuration or programming issue.

 

I have a script that reads data from remote server via socket connection, something like this:

 

...

$fp = fsockopen($conn_host, $conn_port);

 

stream_set_blocking($fp,0);

while (!feof($fp) && !$stop) {

$line = fgets($fp, 1024);

echo($line);

flush();

} //while

stream_set_blocking($fp,1);

fclose($fp);

 

I put it on a web site and it worked fine for several days. Then it stopped working properly. Host provider assured me thy did no do any changes in configuration. They also restarted the server but that did not help.

 

I did some testing and see that the scripts works in following way:

 

1. It opens the socket connection successfully.

2. It reads some block of data

3. Then it hangs up for 30 sec and throws error

  "Maximum execution time of 30 seconds exceeded in line XX" where line # is the line with fgets function.

 

Any idea why it this problem happen? It is really critical issue.

 

Thanks.

 

 

Are you sure the host/port you are connecting to is still active ???

 

Also you may try www.php.net/set_time_limit and raise the script timeout.

 

Also where is $stop being set inside the loop, it seems you have an infinite loop on your hands.

Are you sure the host/port you are connecting to is still active ???

 

Also you may try www.php.net/set_time_limit and raise the script timeout.

 

Also where is $stop being set inside the loop, it seems you have an infinite loop on your hands.

 

1. Yes, I am sure. For testing I just used "http://www.google.com" link. The script shows beginning part of google web page and then suspends.

 

2. It does not help.

 

3. Never mind. It has no relation to real problem.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.