vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Too many connections (https://vborg.vbsupport.ru/showthread.php?t=276301)

pitzerwm 01-01-2012 05:57 PM

Too many connections
 
Recently I have started getting this database error email. It starts at 10:30PM and last about 20-30 minutes after which all is normal.

This is the first of the error:

Database error in vBulletin :

mysql_connect(): Too many connections
/hsphere/local/home/xxxxxxxx/forum.autocareforum.com/includes/class_core.php on line 311

The ip is from China 180.76.5.64

Night before last the host terminated service and this was one of the issues:

->Query summary
Time: 24% (3696 sec) Amount: 20% (31 queries) Rows Examined/Sent: 557 / 502 Avg. Query Exec/Lock Time: 119 / 43 sec.
Used databases: [pitzerw_vb]
Query example: use pitzerw_vb; SELECT * FROM datastore WHERE title IN ('','options','bitfields','attachmentcache','forum cache','usergroupcache','style cache','languagecache','products','pluginlist','cr on','profilefield','loadcache' ,'noticecache','bbcodecache');
|id table rows Extra
|1 datastore 15 Using where

They turned it back on 7 hours later and suggested that it was an optimization issue, so I ran repair and optimization and it said all was fine.

I am running 3.8.4 patch 2

Thanks

Lynne 01-01-2012 06:42 PM

"Too many connections" means the server has maxed out the number of MySQL connections it allows. You can try turning persistent connections off by adding this to your config.php:
PHP Code:

$config['MasterServer']['usepconnect'] = 0

But, if you still have the problem you will have to talk to your host about raising that limit. Also, see this Common MySQL Error Messages

pitzerwm 01-01-2012 07:14 PM

Thanks, I'll give it a try.

--------------- Added [DATE]1325485530[/DATE] at [TIME]1325485530[/TIME] ---------------

Lynne, That didn't solve it. What's with the "attack" at 10:18 PST each day.

Any other options?

Thanks

--------------- Added [DATE]1325530072[/DATE] at [TIME]1325530072[/TIME] ---------------

Is there a way to put their IP somewhere that would stop them on the "outside"?

pitzerwm 01-03-2012 05:59 AM

This is what I got from my host:

Our administration team is monitoring network 24/7 and we block external addresses if we detect abusive activity however if someone is overloading your site using some script from your side which generates too many SQL queries it can be very hard to detect because that address does not generate too much traffic. We recommend rechecking your scripts to prevent that from your side. Our administration team told us that it is possible that someone is abusing your application if the problem occurs at exact same time every day but we don't have any evidence of that, please check your HTTP connection logs available inside /logs/ folder in your hosting plan. You can add any address to deny list in .htaccess file, here are some examples:
http://www.htaccess-guide.com/deny-v...by-ip-address/


I added this to my root directory of the forum:

order allow,deny
deny from 213.186.12.
deny from 180.76.6.
allow from all

Do you think that this is the solution or a possible solution?

Thanks

Lynne 01-03-2012 03:52 PM

I don't know if that will work (and actually doubt it). I am guessing the host has the max_connections set low for you - did you ask them what it is set to?

pitzerwm 01-04-2012 06:39 AM

Update, well, it happened again but the 2 IPs that I put in the .htaccess were not the same, of course, there were about 10 from the normal unwanted places. The host says" that this is from a "script" on my end". Any idea what they are talking about, or a solution.

I asked about the number of connections, no answer yet.

Lynne 01-04-2012 06:06 PM

Of course it's from a script. If you had no pages on your site, then you would never get any errors!

Like I asked before, what do they have your max_connections set to?

You may want to see this - List of questions a user should ask a new host

pitzerwm 01-04-2012 06:23 PM

I'm still waiting for their answer on the number of connections. My question is if this "too many connections" issue cause the long Query times, which is what they terminated service over?

Is there some way to automatically turn off my site from 10:18 to 10:40 or would that really help. Would they just adjust their "script".

Thanks

Lynne 01-04-2012 08:33 PM

You may want to see if they have any sort of caching available to you. You could use the vbulletin datastore_cache (set in the config.php file) and see if that helps.

pitzerwm 01-04-2012 08:43 PM

Thanks. Can you give me the code that would go in the config file? When I put something in the config file, do I need to cycle/reboot something or is it read constantly?

Do you think that these "too many connection" events is causing the Query time issues?

Bill

Lynne 01-04-2012 08:47 PM

Too many connections is separate from the query issue.

You can read about the datastore cache here in the manual - The vBulletin Datastore

pitzerwm 01-04-2012 08:53 PM

thanks

--------------- Added [DATE]1325748986[/DATE] at [TIME]1325748986[/TIME] ---------------

Update: IX gives me 50 connections, its a shared server. They suggested Throttle Policy, set 30/15sec, which I did (their 2nd suggestion to deny whole countries.

The attack still occurred. I can live with this, it started a month ago, why I don't know, but I think/hope that it will someday move on, when they accomplish nothing.

If you happen to think of something, please let me know

Thanks for your help.

pitzerwm 01-06-2012 05:28 AM

Update, Tonight at 10:15 I turned off the site, at 10:19 the "too many connections" emails started?

This isn't what I expected, any suggestions?

Thanks

Lynne 01-06-2012 05:50 PM

People are coming to the site even though it is off.

Have you looked at your access_logs to see what pages they are hitting at the time you get the error?

Boofo 01-06-2012 05:53 PM

Sounds like spiders are hitting the site hard.

Max Taxable 01-06-2012 06:02 PM

Get CloudFlare. Set security to medium, then disallow China.

The attacks would then hit CloudFlare and not you, and as a CDN, CF will also speed up your load times..

You can add any country, or any custom IP ranges in your CF settings.

pitzerwm 01-06-2012 06:12 PM

Lynne, The pages are random, just post/threads in the forum

Boofo, any other solution that you feel will work?

Max, I looked at CF and see there is a free one, do you just sign up and you or they apply it to the forum root?

Thanks for your help.

Max Taxable 01-06-2012 09:27 PM

Quote:

Originally Posted by pitzerwm (Post 2284533)
Max, I looked at CF and see there is a free one, do you just sign up and you or they apply it to the forum root?

Nope you'll change your nameservers to the ones they assign you and do one file edit to make your visitor IP addresses still come out right.

https://vborg.vbsupport.ru/showthread.php?t=259173

pitzerwm 01-07-2012 12:43 AM

Max, I read all of the info, from the other forum/s and it looks like a solution. Did you have any issues? I see where you change the db in the config file and I tested the FTP change, what is the other change that you need to make that they talk about. Is the DNS the actual db "location"?

Lynne, have you seen any issues with CF? Apparently, they have some working relationship with many host, but I didn't see IX in their list.

Thanks again for every ones help

Max Taxable 01-07-2012 12:56 AM

Quote:

Originally Posted by pitzerwm (Post 2284638)
Max, I read all of the info, from the other forum/s and it looks like a solution. Did you have any issues? I see where you change the db in the config file and I tested the FTP change, what is the other change that you need to make that they talk about. Is the DNS the actual db "location"?

All I did was edit the file, then assign my domain the nameservers CF provided. Than in CF you go through all the DNS settings to make sure it picked everything up. On mine, it did no problem.

I have had zero problems with CF and it's been great to have.

You are not editing the config file, you edit class_core.php like this:

Code:

1. open includes/class_core.php

2.

Find: function fetch_ip() { return $_SERVER['REMOTE_ADDR']; }

replace with:

function fetch_ip() { if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { return $_SERVER['HTTP_CF_CONNECTING_IP']; } return $_SERVER['REMOTE_ADDR']; }


Find:

function fetch_alt_ip() { $alt_ip = $_SERVER['REMOTE_ADDR'];

if (isset($_SERVER['HTTP_CLIENT_IP'])) { $alt_ip = $_SERVER['HTTP_CLIENT_IP']; }


Replace with:

function fetch_alt_ip() { $alt_ip = $_SERVER['REMOTE_ADDR'];

if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $alt_ip = $_SERVER['HTTP_CF_CONNECTING_IP']; } else if (isset($_SERVER['HTTP_CLIENT_IP'])) { $alt_ip = $_SERVER['HTTP_CLIENT_IP']; }


3. upload and overwrite


pitzerwm 01-07-2012 01:18 AM

Thanks again Max, where do you "assign my domains"?

Do you use the challenge page?

Max Taxable 01-07-2012 01:52 AM

Quote:

Originally Posted by pitzerwm (Post 2284644)
Thanks again Max, where do you "assign my domains"?

Do you use the challenge page?

The challenge page, it only comes in when CF thinks a bad actor is trying to access your site. It gets its data from Project Honey Pot and is in fact, a product of Project Honey Pot.

I just use the default page, I didn't customize it. But, there's option to do so.

"assign the domain" means, CF will give you new nameservers to assign to your domain, through your host instead of the nameservers you have now.

pitzerwm 01-07-2012 05:17 AM

Thanks max, I guess, I'll give it shot tomorrow.

Boofo 01-07-2012 05:24 AM

It sounds a lot more confusing than it really is once you get going on it, trust me. Max is the man to go to for any advice. ;)

Max Taxable 01-07-2012 02:36 PM

Quote:

Originally Posted by Boofo (Post 2284680)
It sounds a lot more confusing than it really is once you get going on it, trust me. Max is the man to go to for any advice. ;)

And Boofo can now personally vouch for CF's effectiveness!

pitzerwm 01-10-2012 06:08 PM

Max, Do I use my main domain to register with CF, or just the forum's subdomain?

i.e. mydomain.com or forum.mydomain.com

Thanks

Max Taxable 01-10-2012 06:20 PM

Quote:

Originally Posted by pitzerwm (Post 2286111)
Max, Do I use my main domain to register with CF, or just the forum's subdomain?

i.e. mydomain.com or forum.mydomain.com

Thanks

Offhand I would advise use 'mydomain' then make sure all subdomains you want covered by CF are included in the DNS settings in CF.

pitzerwm 01-10-2012 06:46 PM

Thanks again Max for your time.

I'm in the process now of setting it up and I'm at the point that it shows what will be protected/routed to them, and while the main domain and the forum domain have the orange cloud the actual NS (DNS) has the grey cloud. Did I screw something up?

Max Taxable 01-10-2012 09:15 PM

Quote:

Originally Posted by pitzerwm (Post 2286132)
Thanks again Max for your time.

I'm in the process now of setting it up and I'm at the point that it shows what will be protected/routed to them, and while the main domain and the forum domain have the orange cloud the actual NS (DNS) has the grey cloud. Did I screw something up?

You'll have the option of turning any of the grey clouds ON by clicking on them.

pitzerwm 01-10-2012 10:04 PM

Thanks again Max. Ok, I finally got that step completed (CF said that the NS shouldn't be routed that way, KEEP grey clouds.

I have changed the DNS servers at IX, "wait 24 hours" When do I change the code in class_core?

When this "flips" will my site be down until I make that code change?

I went to the class_core.php file and (3.8.4 patch 1) it doesn't have those lines of code to replace

Max Taxable 01-10-2012 11:04 PM

Quote:

Originally Posted by pitzerwm (Post 2286238)
Thanks again Max. Ok, I finally got that step completed (CF said that the NS shouldn't be routed that way, KEEP grey clouds.

I have changed the DNS servers at IX, "wait 24 hours" When do I change the code in class_core?

When this "flips" will my site be down until I make that code change?

I went to the class_core.php file and (3.8.4 patch 1) it doesn't have those lines of code to replace

Put your class_core.php file here as a attachment please.

The change is needed so IPs of you, members and visitors won't all be resolving to cloud flare in online.php and elsewhere on the board.

pitzerwm 01-10-2012 11:29 PM

1 Attachment(s)
ok, Thanks again for your help.

Max Taxable 01-10-2012 11:43 PM

This is the file out of /includes folder?

???

includes/class_core.php is the file needed editing.

Per here:

http://www.cloudflare.com/wiki/VBulletin_3.8.4

pitzerwm 01-10-2012 11:52 PM

Yes, Max that is what I have there, and I double checked and that's what is on the site.

I looked at the files on 3.8.6 that I didn't put up, and it also doesn't have those lines.

Ok, I figured it out, its broken up so find replace doesn't catch it. line 2257

Thanks again for your time and energy.

Max Taxable 01-11-2012 12:03 AM

Quote:

Originally Posted by pitzerwm (Post 2286268)
Yes, Max that is what I have there, and I double checked and that's what is on the site.

Lines 2257-60 in the file you attached. I verified this with mine as well:

PHP Code:

function fetch_ip()
    {
        return 
$_SERVER['REMOTE_ADDR'];
    } 

EDIT: I saw after I posted you figured it out. haha

Boofo 01-11-2012 12:06 AM

Max, you also might want to tell them about the the other option of installing mod_cloudflare on the server if they are using Apache to avoid the file edits.

Max Taxable 01-11-2012 12:10 AM

Quote:

Originally Posted by Boofo (Post 2286273)
Max, you also might want to tell them about the the other option of installing mod_cloudflare on the server if they are using Apache to avoid the file edits.

I did but didn't have the details handy, even mentioned you!:D

Boofo 01-11-2012 12:11 AM

I just had my host install it. Never had to touch anything. ;)

pitzerwm 01-11-2012 12:37 AM

Thanks again, I trust that I have it right. I guess, I made the "spiders" mad, yesterday they attacked at 6:30 in the AM and about 6:30 in the PM. Today they didn't do that.

Max Taxable 01-11-2012 12:39 AM

Quote:

Originally Posted by pitzerwm (Post 2286289)
Thanks again, I trust that I have it right. I guess, I made the "spiders" mad, yesterday they attacked at 6:30 in the AM and about 6:30 in the PM. Today they didn't do that.

Look in /online.php, "Who's Online" check the IP addresses.


All times are GMT. The time now is 02:15 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01315 seconds
  • Memory Usage 1,832KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete