Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-24-2011, 09:25 PM   PM User | #1
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
Connection Reset with Server

All,
I've made changes to my php.ini file so that none of my scripts time out but I believe have an issue that the server that I'm trying to get information from resets my connection. Is there a way to dynamically switch my IP address or something like that to avoid their server resetting my connection? I'm trying to use get_file_contents as I'm crawling through the website. Thanks in advance.

Last edited by treeleaf20; 08-24-2011 at 09:49 PM.. Reason: Gave more information
treeleaf20 is offline   Reply With Quote
Old 08-24-2011, 10:46 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This isn't going to be a problem with PHP.
What are you going to switch your IP to? If you're talking of your client and you have multiple static addresses, then sure. If its on DHCP, then you can ask for a new one, though typically you get the same one back. If you are referring to your server, then you sure don't want to do that.
Have you tried connecting to your site by address instead of by dns?
Fou-Lu is offline   Reply With Quote
Old 08-24-2011, 10:54 PM   PM User | #3
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
So for example, if I wanted to get some information from like yellowpages.com and I was doing multiple file_get_contents and then all of a sudden after a couple minutes (maybe 1 or 2) my connection got reset what would cause this? I'm just doing this through my localhost on my computer so I know that my settings for my php files are ok. When you say connect to the site without dns, are you saying to put in the ip address of yellowpages?
treeleaf20 is offline   Reply With Quote
Old 08-24-2011, 10:56 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
I can't see it throwing a connection reset. I can see it throwing a timeout or cyclic.
Do you get the same behaviour when you use sockets or curl?
Fou-Lu is offline   Reply With Quote
Old 08-24-2011, 11:03 PM   PM User | #5
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
I don't know how to use sockets but haven't tried to use curl yet either. I got a message from localhost that says:

The connection to localhost was interrupted.

My script doesn't output anything, it just does a whole bunch of crawling through webpages and inserts some data into my database. It probably ran for 5 minutes before it gave me this message. I'm also running XAMPP if that makes a difference.
treeleaf20 is offline   Reply With Quote
Old 08-24-2011, 11:07 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Have you tried to set ignore_user_abort and disable the time limit of the script?
XAMPP shoudn't make a difference.
Fou-Lu is offline   Reply With Quote
Old 08-24-2011, 11:11 PM   PM User | #7
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
Here is the PHP file:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 0

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = -1

; Maximum input variable nesting level
; http://php.net/max-input-nesting-level
;max_input_nesting_level = 64

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M

Also I just removed the semicolon in front of the ignore_user_abort so that should be ok now. Does everything look ok now?
treeleaf20 is offline   Reply With Quote
Old 08-24-2011, 11:18 PM   PM User | #8
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
I also noticed this in the documentation:

Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.

Do I have to do something with the Apache configuration to make it higher then 300 or will the ignore_user_abort not make that relevant?
treeleaf20 is offline   Reply With Quote
Old 08-24-2011, 11:34 PM   PM User | #9
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by treeleaf20 View Post
I also noticed this in the documentation:

Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.

Do I have to do something with the Apache configuration to make it higher then 300 or will the ignore_user_abort not make that relevant?
You'll need to configure the Apache. Modify the httpd.conf and alter the timeout to 0.

Edit:
Also, you said this is on a localmachine? Why not just execute via CLI instead of through apache?
Fou-Lu is offline   Reply With Quote
Old 08-25-2011, 02:55 PM   PM User | #10
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
I tried to set this to be 0 on the apache timeout but then the localhost wouldn't work so I set it to just a large number.

It is on a local machine but not sure how to do it with a CLI? Can you tell me how to do that?
treeleaf20 is offline   Reply With Quote
Old 08-25-2011, 03:06 PM   PM User | #11
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
>php -f "/path/to/phpfile.php"
It will run in the command window instead which has no timeout.
Fou-Lu is offline   Reply With Quote
Old 08-25-2011, 03:11 PM   PM User | #12
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
I opened up the CMD window and typed in the following:

php -f "D:/My Documents/xampp/htdocs/folder/file.php"

It gave me the message: 'php' is not recognized as an internal or external command operable program or batch file
treeleaf20 is offline   Reply With Quote
Old 08-25-2011, 03:12 PM   PM User | #13
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You're path isn't registered with PHP. You'll need to specify it:
Code:
>/path/to/php.exe -f "D:/My Documents/xampp/htdocs/folder/file.php"
Fou-Lu is offline   Reply With Quote
Old 08-25-2011, 03:17 PM   PM User | #14
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
Ok, I got that to work now I've got a lot of error messages:

PHP Deprecated: Assigning the return value of new by reference is deprecated in D:\My Documents\xampp\php\PEAR\config.php on line 166

PHP Deprecated: Assigning the return value of new by reference is deprecated in D:\My Documents\xampp\php\PEAR\Config\Container.php on line 111

Then some messages that it couldn't connect to my database becuase I'm using localhost.
treeleaf20 is offline   Reply With Quote
Old 08-25-2011, 03:24 PM   PM User | #15
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
The first errors are backwards compatibility issues: $obj = &new classObject();. Nothing to worry about at this point.
Change you're database configuration to use 127.0.0.1:3306 for its host.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:25 AM.


Advertisement
Log in to turn off these ads.