[TUTORIAL]Fixing login freeze and MySQL problems on LOTF sources for sure!
Those who downloaded some sort of a LOTF source and get it to work, soon faces a problem: login freezes, portal freezes, etc. In the worst cases, even the character account data is corrupted. Well, as this is my first post on elitepvpers, I hope to do a rich contribution for ya all, because this forum helped me to create my own server and learn a new programming language.
Well, let's work:
What you need:
- some CO server source installed and running (if you are reading this, you already have it.)
- Visual C# Express (if you don't have yet, download from microsoft)
If u agree, I will not give u the fishes, but I will teach u how to fish, so u become able to do it anytime, ok? So in this we'll analyze some techniques:
1 - redundant connections
2 - close connections after use
3 - cut unnecessary sql queries
For LOTF, almost all SQL queries are in database.cs; open it in visual C# and you will know you are near one when u see a word containing mysql. Let's start with the connections. Find something similar to this:
Now, u need to invoke this second connection in case the first fails. I will take as example the SaveChar method, but u must do this in all SQL queries:
Resuming: find the query block code, put it inside a try statement and repeat the same query inside a catch, but using the other connection. Do it for all mysql related code.
RESULTS: the capacity of the server is enlarged, but after some time the alternative connection starts to work as much as the main connection, and after some more players log in, both connections start to fail. So, this is not a definitive solution, and is because of that we analyze the 2nd technique:
This, even not resolved the problem, enlarged the server capacity some more and accelerated the database response, diminishing lags, so, it's a good practice. For better understanding, let's use some short code block as example this time:
Code:
public static void Change_GMStatus5(string Acc)
{
MySqlCommand Command = null;
Command = new MySqlCommand("UPDATE `Accounts` SET `Status` = 5 WHERE `AccountID` = '" + Acc + "'", Connection);
Command.ExecuteNonQuery();
}
Add some code, to verify if connection is open and to close it after use. Make it look like this:
Code:
public static void Change_GMStatus5(string Acc)
{
[B] if (Connection.State == ConnectionState.Broken || Connection.State == ConnectionState.Closed)
{
Connection.Open();
}[/B]
MySqlCommand Command = null;
Command = new MySqlCommand("UPDATE `Accounts` SET `Status` = 5 WHERE `AccountID` = '" + Acc + "'", Connection);
Command.ExecuteNonQuery();
[B] Connection.Close();
Connection.Dispose();[/B]
}
Just remember: if u adopt this technique to your server, u must do it around ALL MySQL queries, to put a way to verify connection state, because the connections will be closed, and the system verifier (State.Changed) doesn't work.
LOTF sources have a 5 minute system timer that saves all chars when elapsed, and when we close the server the right way, they are saved too, and some sources have the command /save available for the players, so we can cut some Char.Save() invocations without risk:
in character.cs, find:
Code:
if (DateTime.Now > LastSave.AddMilliseconds(15000))
Save();
just comment these 2 lines with //
(this lines was just saving each char every 15 seconds, causing some overload after we have 6 or more players logged in)
(we need save when the char move? When crossing a portal? NOOOOO!)
If u know C# a little, is possible to find and cut other queries. but be aware: understand what the code does first. In any case, you can debug the server step by step to see the most invoked queries and decide if they must remain or not.
This technique is really effective, although using it alone, the server is not optimized. I recommend use the three improvements together. If u do it, u will have a PRO server.
I can post my results, serving CO on an old Athlon XP 2000+, 512MB ram, Windows XP SP3:
At beginning: server takes about 20 seconds to start; about 6-8 players logged and mysql was denying connections;
Step 1 done (replication): server takes about 20 seconds to start; working without mysql errors at 9 players;
Step 2 done (replication AND closing connections): server takes not even 5 seconds to start, and handled 11 players without errors;
Step 3 done (replication + closing conns - unnecessary queries): server takes less than 5 seconds to start, and worked without mysql errors till now, not even once I registered it using alternate connection; for now I was able to login only 27 characters, being 8 actively playing (but Im sure it handles more, cause we have just 8 computers here )
Srokey forum is fixing problems.. 04/08/2011 - SRO Private Server - 55 Replies http://www.srokey.com/forum/viewtopic.php?f=29& ;t=1587&p=4608#p4608
SWSRO we will have a new update in the next 1/2 weeks, the new update will got:
New map
New mobs
New items in npc
New items in item mall
Here one screen shot, for say bye to scammers:
[REQUEST] Login server for CoemuV2 errors and login freeze. 07/21/2009 - CO2 Private Server - 6 Replies http://i564.photobucket.com/albums/ss81/onlyme64/e rror2.jpg
I get this error when i try to debug the login server. But strangley when i open the login server from bin/release it opens without any errors. When i open it from bin/debug it crashes. When i open the the good login server and game server and try to log in and i get a login freeze. Here is a screeny:
http://i564.photobucket.com/albums/ss81/onlyme64/ error3.jpg
What do i do? :(
[Help]Loggin Freeze on LOTF 03/17/2009 - CO2 Private Server - 15 Replies Title.
So anyone got the right scrpit for fixing it?
I hope anyone got the right scrpit for fixing the loggin freeze.
Thank's
[Help] Fixing Arrows in lotf 09/02/2008 - CO2 Private Server - 9 Replies anyone know how to fix the arrows in lotf when u use them they will actly go away? if so please tell me how
Fixing problems with Script Vessel. 01/18/2007 - Conquer Online 2 - 8 Replies To make ur bot to work again get ur PC date some days before example 02.01.2007.