Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts

    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 10:49 PM. Reason: Gave more information

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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?

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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?

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Have you tried to set ignore_user_abort and disable the time limit of the script?
    XAMPP shoudn't make a difference.

  • #7
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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?

  • #8
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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?

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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?

  • #10
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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?

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    >php -f "/path/to/phpfile.php"
    It will run in the command window instead which has no timeout.

  • #12
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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"

  • #14
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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.

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •