jaymc Posted April 14, 2009 Share Posted April 14, 2009 Hey, Im running an php msn bot My problem is that it loses connection after around 20 seconds. I have spoke with the developer of this and he says it works fine on 90% of servers He has advised that the script is being terminated by the OS / php My question is, what has the power to automatically kill a php script. I have checked php.ini and things such as max_execution_time , set_time_limit are both 10 minutes What other settings control when and if to terminate a php script that it thinks has been running too long Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 14, 2009 Share Posted April 14, 2009 20 seconds is a lot for a webpage. I don't know the exact timeout of browser but some will eventually report a timeout if your expect your script to run for more than 20 seconds. I don't think most visitor will wait that long. If your building a bot or want to run a background job you should check for a cron job instead. Just ask google about crontab/cron job you will find a lot of ressource on how to set a job to run on background at regular interval. I don't know about your environement at all but some shared hosting may have installed something to shut the script after some time. Or it may be the memory requirement that kill the script. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810224 Share on other sites More sharing options...
The Little Guy Posted April 15, 2009 Share Posted April 15, 2009 if your on window, open the command line... and type: php C:\bot.php change C:\bot.php to your bot's location see how long it runs in there Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810351 Share on other sites More sharing options...
jaymc Posted April 15, 2009 Author Share Posted April 15, 2009 Hi Thanks for answers Im running it via ssh php -q bot.php Its my server not a shared host. All enviroment variables such as memory, execution time are more than adequate Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810578 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 How is the bot connecting? If its via fsockopen() then you can specify the timeout as a parameter. You may also need to look at stream_set_timeout(). It's possible that your router could be dropping the connection or possibly firewall. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810744 Share on other sites More sharing options...
jaymc Posted April 15, 2009 Author Share Posted April 15, 2009 I have tried it on two different servers One which is behind my own router another which is in a datacenter Both get killed after 15 seconds, tried with firewall off too Yes it does use fsocket but isnt setting the timeout based on if it cant get a connection as apposed to keeping it running for more than 15 seconds? Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810825 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 Both get killed after 15 seconds, tried with firewall off too Then how do you know if it is not the remote end terminating the connection as opposed to the client. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-810893 Share on other sites More sharing options...
premiso Posted April 16, 2009 Share Posted April 16, 2009 set_time_limit Have you tried increasing the timeout limit of PHP. Chances are PHP is just timing out after the normal time like it is suppose to. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811101 Share on other sites More sharing options...
keeB Posted April 16, 2009 Share Posted April 16, 2009 Still sounds like a php.ini problem. Most distributions have 2 php.ini's. One is for the web and the other one is for the cli. Make sure you're looking at the php.ini for the cli. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811193 Share on other sites More sharing options...
jaymc Posted April 16, 2009 Author Share Posted April 16, 2009 I only have one php.ini file Here are the key settings ;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; max_execution_time = 3600 ; Maximum execution time of each script, in seconds max_input_time = 6000 ; Maximum amount of time each script may spend parsing request data memory_limit = 3024M ; Maximum amount of memory a script may consume (16MB) ; Default timeout for socket based streams (seconds) default_socket_timeout = 3600 ; Maximum size of POST data that PHP will accept. post_max_size = 2048M ; Maximum allowed size for uploaded files. upload_max_filesize = 2048M I have also tried running it from the browser as apposed to ssh Any more ideas? Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811362 Share on other sites More sharing options...
jaymc Posted April 16, 2009 Author Share Posted April 16, 2009 I checked ps aux and its hardly using any RAM or CPU, not to mention the machine has 5GB of ram anyway Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811366 Share on other sites More sharing options...
keeB Posted April 16, 2009 Share Posted April 16, 2009 Can you please post any errors that happen? Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811514 Share on other sites More sharing options...
jaymc Posted April 16, 2009 Author Share Posted April 16, 2009 Hi There are no errors. The msn bot will function perfectly but goes offline after 20-30 seconds. When that happens it is no longer in ps aux The guy who made it said he has heard of this issue from other people who use the bot but assures it works fine on systems he has tested which include windows/linux Hence, he believes enviroment issue such as php.ini setting / operating setting Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-811710 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 You're sure there are no errors? So you run: php bot.php And in the end it just terminates without printing anything? Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-812035 Share on other sites More sharing options...
jaymc Posted April 17, 2009 Author Share Posted April 17, 2009 Correct The bot signs into msn, stays online for 20 seconds If you send it messages it will function as expected as in return messages back to you Strangely, by talking to it this causes it to stay online, until you stop talking Perhaps because the socket is active But no errors, just a general timeout kind of thing when there is no communication to the bot from an msn user Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-812379 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 I bet what's happening is there's a timeout from MSN on the socket. Clasically, In order to keep a socket alive you need to send a NOOP (or similar.) I think the extensive testing the author told you about was on a really active bot Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-812399 Share on other sites More sharing options...
jaymc Posted April 17, 2009 Author Share Posted April 17, 2009 The developer has just signed the bot in his side and it stayed online Bare in mind the only person on its contact list is me and of course I did not speak to it.. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-812447 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 The fact that you're not getting an error is what's troubling me still. Are you familiar with XDebug? If you could run it through the debugger to find out where it's exiting it could give more information. Quote Link to comment https://forums.phpfreaks.com/topic/154128-script-killed/#findComment-812479 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.