Jump to content

ev5unleash1

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ev5unleash1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My bad about the double post. So a little update. I have updated Apache 2.4.7 and PHP to 5.4.12 and I still have the issue. The only improvement is the amount of time it takes the virtual host to lock down. Right now I have it at about 3-4 hours until it bites the dust (1-2 hours at around 600 simultaneous connections). When it does lock down, it will simply reply with "CONNECTION REFUSED". Again, other virtual hosts will continue to operate.
  2. Hi Everyone, I currently have WAMP installed on a Windows 7 with the specs below: Windows 7 64-bit WAMP -Apache 2.4.4 (Win64) -OpenSSL 1.0.1d -PHP 5.4.12 8 GB of DDR3-1600MHZ RAM (2x4GB) 128 SSD Intel Core i3-3217U @ 1.8GHZ The problem I am having with this server is that it will stop fulfilling SSL-based requests after a certain amount of time. This server takes about 500-600 SSL based connections at any time so it is under a bit of a load. However, I don't have any bottlenecks in terms of performance. HTTPD.exe takes about 1.5GB of RAM on average and uses about 5-15% of the CPU. The interesting thing is that the non-SSL virtual servers will respond properly. I can view the server stats via the status_module and access other virtual servers that serve different domains. When I view the status of the server I see a large amount of connections that are stuck in the "_" - Waiting for connection state. My machine that got the "ERR_CONNECTION_REFUSED" error message is also there under "Waiting for connection". So far the only fix is restarting the webserver every 5-10 minutes. Any ideas? Thanks,
  3. @requinix That's my old script regarding a socket server. This is a completely different where here I'm accepting socket connections as opposed to connecting to one.
  4. Hi all, I'm currently trying to run a PHP Socket Server though I'm having trouble with responding after so many reconnects. It would seem after 3-5 reconnects that it will just stop taking connections altogether. Any ideas? Basically I want the script to do as it does right now, but be able to accept a new connection at any time. Though it only has to be one connection, so kicking the previous connection off doesn't matter to me. Thanks, <?php echo "Web Socket Script = Coded in PHP" . PHP_EOL; echo $custom; error_reporting(0); function action_put($probe) { $memcache = new Memcache; $memcache->connect('localhost', 11211) or $error = "Memcache: Could not connect to Cache server"; $memcache->set('key', $probe, false) or $error = $error . ". Failed to save data at the server."; if(isset($error)) { echo "Data not stored: " . $error; } else { } $respond = $memcache->get('key'); } function action_get() { $memcache = new Memcache; $memcache->connect('localhost', 11211) or die ("Memcache: Could not connect to Cache server"); $respond = $memcache->get('key'); return $respond; } function cachetodisk() { $cache = action_get(); file_put_contents('probe.txt', $cache); } function disktocache() { $disk = file_get_contents('probe.txt', 'r'); action_put($disk); } /* Register Shutdown on close */ register_shutdown_function('cachetodisk'); $respond = disktocache(); /* Allow the script to hang around waiting for connections. */ set_time_limit(0); ini_set('default_socket_timeout', '0'); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush(); $address = '10.10.2.4'; //$port = 90; if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } if (socket_bind($sock, $address, $port) === false) { echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; } if (socket_listen($sock, 5) === false) { echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; } do { if (($msgsock = socket_accept($sock)) === false) { echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; break; } /* Set Default Data */ /* Send instructions. */ //echo "Client connected from: "; if ($_SERVER['HTTP_CLIENT_IP']) $visitorip = socket_getpeername($sock, $address, $port); echo $visitorip; $msg = "Welcome to the PHP Test Server." . PHP_EOL; socket_write($msgsock, $msg, strlen($msg)); $echo = "000000"; if($probetest != true) { action_put($echo); } $respond = action_get(); socket_write($msgsock, $respond, strlen($respond)); do{ //Respond once $respond = action_get(); if($respond == $respondnew) { usleep(1000); //1ms responce time } else { //Removed bunch of if else statements that don't really matter. $echo = $echo . PHP_EOL; $respondnew = $respond; if(socket_write($msgsock, $echo, strlen($echo)) === FALSE) { $connection = "closed"; } socket_close($socket); usleep(1000); //1ms responce time } } while (isset($connection) != TRUE); unset($connection); // if($probetest == TRUE) { shell_exec('C:\wamp\bin\php\php5.4.3\php.exe "C:\wamp\wwwshare\car\sockettest2.php" > NUL'); die();} } while (true); socket_close($msgsock); socket_close($sock); while($i = 1); ?>
  5. The server is configured with default_socket_timeout = 0 and both are my own personal servers. The socket host is a WAMP server and the client that I'm having trouble with is a Linux server.
  6. I thought about this, but the commands work as soon as a start the script. Only after I send a few commands and wait a little bit is when the script will stop responding. I did a packet mirror on the Pi and it seems that it stops accepting or kills the socket connection at that time. I double checked my server by having putty connected to the same script but on a different port and that doesn't seem to stop responding.
  7. 1. This script will connect to another telnet server and wait for commands to be sent. It will interpret what is sent and execute certain commands based upon it. The shell code can range from anything to executing another PHP script to sending a reboot command. I'm nohuping because I found it was the best way to restart the script when the connection fails, thus waiting for a connection when the previous one fails.
  8. Hi guys, I'm at a standstill with this telnet script I'm trying to perfect. The scripts job is to interpret a command on the telnet connection and execute different commands based upon it. It's executed as a standalone script by the system, so no HTTP requests are involved. The script works for what I need, although after about a minute or so the script just freezes. Though the process still exists and I'm forced to re-open it. The server doesn't seem to hang at all, just the client side stuff. Hopefully I can get some insight as to why it hangs, thanks! <?php set_time_limit(0); //error_reporting(E_ALL); error_reporting(0); /* Get the port for the WWW service. */ //$service_port = getservbyname(86, 'tcp'); $service_port = 86; /* Get the IP address for the target host. */ $address = gethostbyname('removed'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } else { echo "Creating Socket... [OK]\n"; } echo "Attempting to connect to '$address' on port '$service_port'..."; $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "[OK]\n"; echo "Script Running...\n"; } $in = "Connect"; echo "Sending connect to server..."; socket_write($socket, $in, strlen($in)); echo "OK.\n"; //echo "Reading response:\n\n"; function probe($data) { $remote = $data; /* Code intentionally removed. Just saw variable and executed something based upon what it saw. */ if(strstr($remote, "rpi_reboot")) { shell_exec("sudo reboot"); } usleep('1000'); //10ms } $outnew = "0"; while ($out = socket_read($socket, 1000, PHP_BINARY_READ)) { echo $out; if($out != $outnew) { probe($out); $outnew = $out; usleep(1000); //To have a fast response time } else { } } /* When connection fails, kill all processes */ shell_exec("shell code here"); sleep(1); echo "Closing socket..."; socket_close($socket); echo "OK.\n\n"; sleep(1); exec("nohup sudo php /var/www/telnet.php > /dev/null 2>&1 &"); //Close process and open another exit(); ?>
  9. Thanks so much for the assistance. I'm looking at your code and I see the array up to a certain point. The amount of rows could be 500... Also my post above better asks my question, I've also included which data is being POSTed to the script.
  10. To make my question a little more simple. For every checkbox that is checked, I want this script to add "chk $rownum" to $grade (file). When the checkbox isn't checked, nothing should happen. When checked the checkbox has the value of the row number it is in. Hope that's better Thanks, Evan J
  11. Hi Everyone, I'm definitely a beginner when it comes to PHP so please bare with me. I'm working on an application which uses .CSV files to store data. Long story short, I have a checkbox for each row of data with the ID as the row number. I'm trying to create a script that will save the state of the checkboxes (checked/unchecked), then when loaded it will recall the saved state. I'll do my best to create a script to better explain what I'm trying to do. Here is my save script: <?php session_start(); $grade = $_SESSION['grade']; if (isset($_POST['submit'])) { while ($checkbox <= $checkbox) { echo "Okay"; $towrite = " chk" . $_POST['checkbox']; " "; } //Checking to see if the variable was posted, then sets a variable to correspond to the checkbox. //Will write " chk1 " if checkbox is selected //Want this incremented and written so on for every checkbox $_POST-ed. //Below will write the selected checkboxes to file $myFile = "csv/" . $grade . ".php"; echo "<p></p>"; echo "Opening " . $myFile; $fh = fopen($myFile, 'a+') or $_SESSION['changesubmit']='fail'; fwrite($fh, $towrite); fclose($fh); } ?> Basically I want to be able to do this execution with all checkboxes and I'll be fine. But it seems repetitive and extremely messy if I were to copy and increment the checkbox name. For each Row a checkbox incremented is named (i.e Checkbox1, Checkbox2, Checkbox3,). I want this script to save to a file with chk1 if the checkbox is selected and so on with every checkbox. I have never done something this as you could probably guess from my poor PHP example. Any guidance or pre-created script to help me learn would be great. Thanks, Evan
  12. Sorry if I wasn't clear about my directory issue. So far I cannot include any file that isn't in the same directory as the file that is including it. For example: File path "/php/scripts/request.php" cannot include a file from "/php/scripts/morescripts/filetoinclude.php". I clearly remember being able to do this in the past, so why aren't I able to now? I've fiddled around with "allow url include" but it still doesn't follow through. Error I'm getting at the moment: Warning: include(actions/clearverify.php?grade=11th): failed to open stream: No error in C:\wamp\stratus\apps\coursechange\admin\clear.php on line 16 Warning: include(): Failed opening 'actions/clearverify.php?grade=11th' for inclusion (include_path='.;C:\php\pear') in C:\wamp\stratus\apps\coursechange\admin\clear.php on line 16 Before I somehow got Error: The stream is currently unavailable, or something around that... I also can't seem to find any insight anywhere on the internet. Thanks for the swift replies everyone!
  13. Hi all, Currently, I'm creating an application with a constant variable that I wish to use throughout the site. I can easily use the include('thisfile.php'); but when I try to include the file from a lower directory like this include ('thisfolder/thisfile.php'); it doesn't seem to work. I can include and open other files like .txt documents but jut not .PHP files. I've looked through the PHP settings but I cannot see any setting that would remotely relate to the problem I am having. Any advice would be awesome at this point, I'm stumped.
×
×
  • 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.