MySQL Abruptly Refusing Remote Connections - php

UPDATE
So I completely disabled my server's firewall and it appears to be the culprit. I had tried to disable certain rules before but disabling the whole thing worked. Very frustrating, but problem solved I guess... I think the key indicator that it was the firewall was because it happened at exactly midnight when my server likes to apply updates and such.
This is pretty strange to me, I have a server downstairs that hosts my websites and MySQL servers and it has been running for years without many issues. I have 2 routers bridged together behind my modem and my server is behind one of them. All other devices connect via WiFi. All of the proper ports are open on the router and I have users configured in MySQL that haven't changed and have been working fine this whole time.
So last night I was working on a project and I decided to sync everything with a backup on my SkyDrive. I have a scheduled backup for MySQL that runs at midnight (daily) and it just turned over to midnight so I decided to open my network and watch the file get populated before I sent a copy to my SkyDrive. After the backup was complete (which it did successfully), I was going to continue to work on my program but all of a sudden I can no longer connect via my local network to the MySQL server. I'm using PHP and my connection string never changed and all other MySQL admin tools don't connect. The live site works fine, so MySQL was definitely running and working but no remote connections were being accepted. Why is this happening all of a sudden?
Things I've tried :
I did notice that my logs were packed full of BINLOG errors so I turned off the binlog since I recently turned it on (a couple weeks ago).
Restarting MySQL
Turning off Windows Server 2008 firewall (temporarily)
Connecting from a different device (mobile phone, tablet), no luck
Temporarily allowing port 3306 on my router
Checked server logs for intrusion attempts, none present...
Setup :
PHP 5.4 on local machine and server
Windows Server 2008 Enterprise (on server...)
MySQL Version 5.5.25a
Does anyone have any clue as to what's going on here? I'm going to reboot my server when the load is low and see if this helps any, I will update this once it comes back online.

So I completely disabled my server's firewall and it appears to be the culprit. I had tried to disable certain rules before but disabling the whole thing worked. Very frustrating, but problem solved I guess... I think the key indicator that it was the firewall was because it happened at exactly midnight when my server likes to apply updates and such.

Related

xampp apache server up and running, yet bad request

I got some trouble with my xampp on Win 10, as so many have had before me...
It's the same old port problem with skype and IIS.
I used to quit skype and stop the world wide web publishing service, but am sick of having to go through the whole ordial every time I start xampp.
so yesterday I changed the ports for my apache server and ecerything worked fine.
started up today and boom...localhost couldn't find my pages.
So I checked for port problems in xampp...there were none! apache was up and running(as were mysql server and filezilla). no error messages, nothing.
I resetted the ports to 80 and 443. killed of skype and the iis and everything worked fine again. Now whenever I change the ports, it will not run.
I did everything according to here:
How to change XAMPP apache server port?
(I changed the ports in httpd.conf, httpd-ssl.conf and in service and port settings )
I just don't get it. why it won't run with changed ports(and yes I checked the ports for being empty).
atm I have changed the port 80 -> 8024
and port 443 -> 1337 (no matter what I change this port to it always throws bad request)
8024 works fine. I can get to the dashboard via localhost:8024
but localhost:1337 gives me a bad request.
any suggestions, or similar encounters?
For now will have to continue using standart ports and kill of the 2 processes, but I really wanna skip that in the future.
I used port 80->8024
and port 443->448 yesterday and it worked fine...really weird...
Ok so that means your system has Microsoft IIS installed or one of the other bits of MS technology that reports that signature, they are doing that on later versions of Windows for some reason.
If you are not intending to use it you can uninstall it, it is not an integral part of windows so its being uninstalled wont effect normal operations of windows, and if you need to install it again later, it comes as part of the standard OS so you wont need to do anything perticularly clever.
So go to Start -> Control Panel -> Programs and Features
Click the 'Turn windows features on and off' link in the left hand menu.
Wait for the list to load and then find 'Internet Information Services'
Un check the check boxes for the following items ( you may not see all of them ), and there may be others I done know about. You may have all of these or just some of these.
IIS
Web Deploy 2.0 (Web Deployment Agent Service)
MS Sql Server Reporting service.
BranchCache ( Windows 8.1 )
SQL Server VSS Writer
List of possible service names not sure how up to date this is.
Tutorial on how to find what ports are in use on your system and what app is using them
Windows will then have a think for a while and then remove those applications, you will probably be asked to reboot to complete the uninstalls.
Reboot anyway when the uninstalls are complete.
Then try XAMPP again

Apache localhost not responding to clients until reset

I have setup a local server on a regular desktop (not a server desktop) and have 3-4 client machines accessing the local web application I developed from the server via a WIFI router (server is connected to router via cable. All clients via WIFI).
When two of the clients are connected to the application all is well, but when a third (or more) machine joins in there are periods where each machine does not get any service from the server (the application webpage remains loading until I manually reset Apache on the server via services). At times the server responds when one of the clients refresh their page but most of the time I have to perform a reset of the Apache server.
This occurs roughly once an hour on average (6 hours of continuous usage) as the clients are using the application.
Server is running Windows 7 and Apache v2.4 with PHP v5.4
Server and all client machines are running AVG internet security
Firewall is handled by AVG Internet Security
Is this issue due to the code in my application, desktop not being able to manage requests like a server machine, antivirus or a mix of the three?
If so, how can I set-up the server to reset automatically?
Thanks
UPDATE
It is a application where users write reports on files after reviewing information
-Frequent sql requests for file data
-No images
-Some pages contain multiple sql queries that represent the page content
-Network has no internet connection
-Code does not make requests for external information from the internet
-All client machines run the application on Google Chrome web browser
But it rarely happens but sometimes the amount of connection is restricted by the third-party interface being used by the application. We are unable to figure out the reason unless having more details like what content of your app, and the error code apache or HTTP returning.
This kind of situations is difficult to track, especially on Windows where diagnostic tools aren't as readily available as on other platforms.
I suppose you can try and check the antivirus by either running server and clients with no antivirus at all for some hours, or disabling and re-enabling the antivirus when the hangup occurs.
Apart from that, you would need to pinpoint where the error occurs:
in the connection stage (Windows OS is the problem)
in the response stage (Apache is the problem - try fiddling with the child spawning parameters)
in the management stage (PHP is the problem - you can probably check this by changing the setup from PHP-as-a-module, and PHP-as-CGI-application)
in the response stage (that is, connection to the SQL server). You can check this by setting up some pages that use different combinations of session, database, and output buffering and see whether those pages remain reachable even when the application is hung up.
For an example of the last, if a page such as
<?php print date("H:i:s"); phpinfo(); ?>
remains reachable and correctly refreshes (that's why the date() command) even when the app does not respond, this demonstrates that Windows, Apache and PHP are "innocent", and either the SQL server has issues, or you do not interface with it correctly. It might be for example be the case (though unlikely in this instance) that the resident PHP module is accumulating connections to the SQL server and not releasing them, so that after a while you need to stop Apache (thereby freeing the module) and restart.
If this were the case, even if it's not a "real" fix, you can set up Apache so that all children die and are replaced after a small number of requests (once it was 150, but when leaks all but disappeared, I believe that the default became 0 -- Apache children no longer die. Check it out, I might well misremember).

postgresql query hangs indefinitely over VPN - new firewall

We have a product where a local linux machine "SCANNER" does some polling on a local network and then stuffs information into a database in our cloud server over an OpenVPN connection, using pg_query (server is running PostgreSQL 9.5.5).
There is a PHP (5.5.9) daemon on SCANNER that checks the database in a 'while' loop for work to be done. This has always worked great, and continues to work great on all of our client networks, except for one, which has recently developed a bizarre problem.
After they upgraded their firewall (a Checkpoint 5200, and as far as we can tell, all the rules are correct to allow traffic from SCANNER to our cloud server over the VPN), one query in one script hangs indefinitely. Here are the symptoms we have noted:
Most of the time, the query works fine and the script continues. Every once in a while tough, the pg_query() call blocks and never returns. It's not that there's an error; the call literally blocks forever (or many hours until we manually restart).
This query has been the same for a long time, and we have never had this problem at any of our other clients, nor at this client until they changed their firewall.
We can tell from watching the pg_stat_activity table on the cloud server that the query does make it to the cloud, and then sits in that table forever. In every case, pg_stat_activity.state='idle' and pg_stat_activity.waiting=false
During this time, we can still ping the cloud server from SCANNER over the VPN, and we can continue to successfully query its remote database from other scripts on SCANNER, and from SCANNER's command line.
This client happens to have two different SCANNER machines, on different subnets but behind the same firewall. This problem can occur at any time on either one, but doesn't necessarily occur at the same time on both (at least not with any statistical significance).
If we restart the daemon, the problem is temporarily resolved. But it usually recurs sometime between 2 seconds and a few hours later.
We are looking for any input that might solve the problem, whether it is related to our application or the firewall itself (which we have been given permission to modify as needed). Feel free to ask any clarifying questions.
Thanks in advance!
Check Point firewall has a lot of advanced threat protections, depending of acquired blades, the device can be blocking communication between your database and application. Try to use Check Point log tools (Tracker, SmartEvent or NGSE) to filter Firewall logs. Filter all events where your source or destination are your Scanner or database server IP adresses. If you get some drop ou block into your TCP Packets, logs will show that.
If your firewall topology uses Cluster configurations try to check your configuration, it could be misconfigured and database TCP session are active but packets are using another network path.
If you are using Check Point VPN Client, try to update it to last version and update your firewall device with last update packages (Take).
If the problem persists, get evidences to comprove that your communication without Check Point hardware doesn't stop and some evidences of your problem and ask to your Check Point solution provider to open a case with Check Point.
We solved the problem. Technically, we never figured out exactly why it was happening, but UDP packets were getting received by the VPN server in an incorrect order, or sometimes not at all. The firewall didn't give us any indication that it was doing this, so as best we can figure it was an unlogged side-effect of CheckPoint's multiple layers of threat protection.
We switched over to using OpenVPN over TCP instead of UDP, and that seems to have solved the problem. Hopefully we don't suffer any adverse effects from that in the long-term!

PHP on Linux randomly fails to connect to Microsoft SQL Server 2005

(Not a Linux guru!) At work we have for the past month had a serious issue that we haven't been able to solve. From a server running Ubuntu-Linux we are using PHP to connect to a server running Microsoft SQL Server 2005. This has been working without problems for a long time. At the start of February 2013 we moved the SQL Server machine into the same core network as the Linux-machine, which involved changing IP-address on the Windows-server running SQL Server 2005.
After this operation we've had issues connecting to the SQL Server from this particular Linux-machine. Maybe one out of 1000 connections fails with the following error message:
PHP Warning: mssql_connect(): Unable to connect to server
I'm not aware of any other changes to either of these two servers. We've tried to look at 'everything'.
FreeTDS
php.ini adjustments
IP-address in SQL Server Configuration Manager
Unlimited number of concurrent connections in SQL Server
Network and firewall issues (No packet loss during 24 hours)
Any suggestions to how we can pursue error searching for this problem? Any more info anyone would like to know about this setup? It's kinda serious for us since many of our cronjobs fail to execute normally due to this random connection problem.
Rgds,
Sven David, Norway
Very difficult to diagnose from an external perspective, however, it feels like a networking issue rather than php/sql config. Presumably, because it's intermittent, it's not mssql functions/extension. Very little is truly random!
Perhaps approach this by writing a script that monitors the servers (both hosts) vital stats - like a heartbeat: IPs, DNS, DHCP?, requests etc and setting it to record anomalies/alert you when any element changes on either host or connect requests fail...
Probably worth posting on other SE sites too - not just Stackoverflow.

Connecting to SQL Server very slow

I have a standard php app that uses SQL Server as the back-end database. There is a serious delay in response for each page I access. This is my development server, so its not an issue with the live setup, but it is really annoying for working on the system.
I have a 5 - 8 second delay on each page.
I am running SqlServer 2000 Developer Edition on a Virtual Machine (Virtual PC).
I have installed SqlServer on my development machine but get the same delay.
I have isolated the issue to the call to mssql_connect (calling mssql_pconnect has no effect)
It is a networking issue on how I have set up (or not set up, since I didn't really change default config) SQL server. It's not a strictly a programming issue but I thought I might get some valuable feedback here.
Can anyone tell me if there is a trick, specific set of protocols, registry setting, something that will kill this delay?
I was also experiencing a 5-10 second delay on every connect, using the official Microsoft SQL drivers for PHP (as suggested by #gaRex) - none of the answers posted here solved it for me.
As suggested by #ircmaxell, my problem was a DNS issue - and the solution was to edit the \windows\system32\drivers\etc\hosts file (your local local host file) and add the name of my own machine to it.
In the "system properties" dialog, find the "computer name" of your machine - then add a line like 127.0.0.1 my-computer to your local host file.
For me, the delay occurred once more, on the following attempt to load the page - after that, it was super fast, no delay at all.
Note that this problem may occur even on a physical machine, not only on a VM.
I came across network issues when running virtual pc, everything network related is slow, try adding this entry on your registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Create new DWORD value named DisableTaskOffload and set its value to 1.
Restart the computer.
It worked for me, source.
Is it perhaps a DNS issue? I know that MySQL does a reverse DNS lookup on each login (not each connection). If you don't have a reverse dns record for your server (or your dns is slow) it can cause a major delay at login. There's an option in MySQL to disable that. I'm not sure about SQL Server, but I'd assume it may be doing something similar...
I remember the same problem, but forgot, how we have solve it.
To clarify please specify exact connect strings, your SQLserver versions and also try to start this old good utility c:\WINDOWS\system32\cliconfg.exe, which is also can bring some light.
Yes, I know, it's from 2k, but guys at m$ don't like to create client tools from scratch.
Also try to get "right" mssql client dlls for PHP.

Categories