MySql Error. Buffer Maxing Out?

02/07/2011 22:20 stealarcher#1
After I recoded my mysql system, I have been getting a weird ass mysql error after around 6-7 hours typically. After I get the error my mysql fails (wont let me reconnect) and I have to restart my dedi for the mysql to actually work again.

These are the errors:
Code:
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
   at System.Net.Sockets.Socket.DoBeginConnect(EndPoint endPointSnapshot, SocketAddress socketAddress, LazyAsyncResult asyncResult)
   at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
   at MySql.Data.Common.StreamCreator.CreateSocketStream(IPAddress ip, Int32 port, Boolean unix)
   at MySql.Data.Common.StreamCreator.GetStream(UInt32 timeOut)
   at MySql.Data.MySqlClient.NativeDriver.Open()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at ConquerSx.Database.MySqlReader.TryFill(MySqlCommand command) in C:\Users\Chris\Desktop\source\source\Database\MySqlReader.cs:line 72
   at ConquerSx.Database.MySqlReader..ctor(MySqlCommand command) in C:\Users\Chris\Desktop\source\source\Database\MySqlReader.cs:line 19
   at ConquerSx.Database.Core.Loadconfig() in C:\Users\Chris\Desktop\source\source\Database\Core.cs:line 11
   at ConquerSx.Program.Main(String[] args) in C:\Users\Chris\Desktop\source\source\Program.cs:line 85
Saved.
I dont really need a step by step explanation, just need to know what can cause this error so i can fix it. I searched google, but it actually failed me for once. Anyone have any ideas on why the buffer is maxing?

FYI: The mysql system creates a new connection every query, and closes it right after. Figured this may be causing some of the problem, but I watched the mysql monitor and it stays below 30 connections.
02/07/2011 22:25 Syst3m_W1z4rd#2
ConquerSx explains it all.
02/07/2011 22:27 .Beatz#3
Quote:
Originally Posted by stealarcher View Post
After I recoded my mysql system, I have been getting a weird ass mysql error after around 6-7 hours typically. After I get the error my mysql fails (wont let me reconnect) and I have to restart my dedi for the mysql to actually work again.

These are the errors:
Code:
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Exception: Exception of type 'System.Exception' was thrown.
   at MySql.Data.MySqlClient.NativeDriver.Open()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at ConquerSx.Database.MySqlReader.TryFill(MySqlCommand command) in C:\Users\Chris\Desktop\source\source\Database\MySqlReader.cs:line 72
   at ConquerSx.Database.MySqlReader..ctor(MySqlCommand command) in C:\Users\Chris\Desktop\source\source\Database\MySqlReader.cs:line 19
   at ConquerSx.Database.Core.Loadconfig() in C:\Users\Chris\Desktop\source\source\Database\Core.cs:line 11
   at ConquerSx.Program.Main(String[] args) in C:\Users\Chris\Desktop\source\source\Program.cs:line 85
ServerIP: 64.74.97.228
ServerIP: 64.74.97.228
System.NullReferenceException: Object reference not set to an instance of an object.
   at ConquerSx.PacketHandling.PickItemUp.Handle(GameClient GC, Byte[] Data) in C:\Users\Chris\Desktop\source\source\PacketHandling\PickItemUp.cs:line 15
   at ConquerSx.PacketHandler.Handle(GameClient GC, Byte[] PData) in C:\Users\Chris\Desktop\source\source\PacketHandler.cs:line 651



System.NullReferenceException: Object reference not set to an instance of an object.
   at ConquerSx.Database.MySqlReader.Read() in C:\Users\Chris\Desktop\source\source\Database\MySqlReader.cs:line 94
   at ConquerSx.Database.items.NewItem(Item Item, UInt32 PlayerEntityID) in C:\Users\Chris\Desktop\source\source\Database\items.cs:line 71
Saved.
I dont really need a step by step explanation, just need to know what can cause this error so i can fix it. I searched google, but it actually failed me for once. Anyone have any ideas on why the buffer is maxing?

FYI: The mysql system creates a new connection every query, and closes it right after. Figured this may be causing some of the problem, but I watched the mysql monitor and it stays below 30 connections.
Just an idea and not really helping with the error, but why don't you have 1 constant open connection to MySql and then send everything through that instead of opening up new connections all the time... Less Stress = Less Lag = Better Server

Because in all honesty you will run into alot of problems when you have more than 10 people trying to connect...

You have to think.. each query = 1 MySql connection... If 50 people log in and then do something that needs a save, thats 50+ MySql connections opening and then opening again to save something else...

Just seems a bit errr "Stupid" to have your MySql like that < Not meaning to flame :)


As for the Buffer Maxing out I have never seen that error before so unfortunatly can't help you out buddy
02/07/2011 22:28 stealarcher#4
Well, ive always heard of mysql timing out crashing etc, and this way i figured it couldnt do that rofl.
02/07/2011 22:29 .Beatz#5
Quote:
Originally Posted by stealarcher View Post
Well, ive always heard of mysql timing out crashing etc, and this way i figured it couldnt do that rofl.
Yeah but this way you are more likely to flood the MySql connections and then max out the pool and crash the server that way
02/07/2011 22:31 stealarcher#6
hmm, may be right, ill try it out with a solid connection and see how it goes then.
02/08/2011 08:24 Syst3m_W1z4rd#7
Why don't you just use Immunes or Impulse MySQL?
02/08/2011 10:26 coreymills#8
u cant download Impulse's source anymore the download was removed
02/08/2011 12:12 .Beatz#9
Actually you can download the source, if you go down the first page on the thread then you will see alot of download links.
02/08/2011 13:31 Syst3m_W1z4rd#10
Quote:
Originally Posted by coreymills View Post
u cant download Impulse's source anymore the download was removed
Also he posted the way he handle MySQL if you look in a thread here on first page.
02/08/2011 15:01 stealarcher#11
I believe impulses source creates a new connection each query as well. He uses using (connection) which disposes it and creates it, and opens it every time. Forgive me if im wrong, but im pretty sure it does.
02/08/2011 16:23 .Beatz#12
Quote:
Originally Posted by stealarcher View Post
I believe impulses source creates a new connection each query as well. He uses using (connection) which disposes it and creates it, and opens it every time. Forgive me if im wrong, but im pretty sure it does.
No Impulse uses a "solid" connection

It open up when the source does and stays open and sends everything through that connection...
02/08/2011 18:18 stealarcher#13
Hmm, i looked through his source. it calls a void called SelectConnection, which gets the mysql connection. In the mysql connection its set to return new. Isnt that creating a "new" connection every time the SelectConnection is called?
02/08/2011 18:20 Korvacs#14
Yes it is, and theres nothing really wrong with creating a new connection everytime you need one, the majority of websites work in this fashion.
02/08/2011 18:26 stealarcher#15
@Korvacs
Yeah, thats what I was thinking. I didnt think there was anything wrong with it, and figured it would prevent the connection from timing out etc that way. But sense this error isnt caused by too many connections obviously. Any idea what causes it?