[Help] 5095 StarServer.

10/10/2010 00:22 killersub#1
alright so I've recently encountered this problem. I have not made any "Major" modifications to the StartServer void just a few(I have tried everything but still nothing)... but I have token the ones I put in out and it still tells me this:

Quote:
The type initializer for 'CoEmu_v2_GameServer.Nano' threw an exception.
here is my StartServer void:

Code:
public static void StartServer()
        {
                QuizShowInfo[(byte)1] = "Dany";
                QuizShowInfo[(ushort)1] = 245;
                QuizShowInfo[1] = 100;
                QuizShowInfo[(byte)2] = "Lord";
                QuizShowInfo[(ushort)2] = 244;
                QuizShowInfo[2] = 200;
                QuizShowInfo[(byte)3] = "Quiz-Master";
                QuizShowInfo[(ushort)3] = 243;
                QuizShowInfo[3] = 400;
                GenerateKey();
                Struct.LoadItems("items.txt");
                Struct.LoadItemPluses("itemadd.ini");
                Struct.LoadMaps();
                Struct.LoadMonsters();
                Struct.LoadNpcs();
                Struct.LoadPortals();
                Struct.LoadServerskills();
                Struct.LoadTNpcs();
                Struct.LoadFeatures();
                Struct.LoadGuilds();
                Database.Database.LoadRevivePoints();
                Database.Database.LoadEnchantData();
                Database.Database.LoadTops();
                //Database.Database.PurgeGuilds();
                Console.WriteLine("This program is a branch of CoEmu.Nano, property of the CoEmu Foundation.");
                Console.WriteLine("[GameServer-Init] Creating Game Thread..");
                Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();
                Console.WriteLine("[GameServer-Init](Game Thread) Success.");
                Console.WriteLine("[GameServer-Init] Creating Auth Thread..");
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                Console.WriteLine("[GameServer-Init](Auth Thread) Success.");
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                SummonedGuardsThread = new CoEmuThread(); SummonedGuardsThread.Start(SummonedGuardsCheck);
                GuardsThread = new CoEmuThread(); GuardsThread.Start(GuardsCheck);
                BroadCastTimer = DateTime.Now;
                RandEventTimer = DateTime.Now;
                PkTournyStarTime = DateTime.Now;
                TradePartnerCount = DateTime.Now;
                LastMobsMove = DateTime.Now;
                LastDMapCheck = DateTime.Now;
                CheckWalk = DateTime.Now;
                GuildScores = DateTime.Now;
                LastUpdateSite = DateTime.Now;
                LastGuildPoints = DateTime.Now;
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
much help would be appreciated. :handsdown:
10/10/2010 01:23 { Angelius }#2
nothing is worng with this void
your Problem is in Accepting a New Connection though
plus you should look at this void like its just a list for the stuff that the server well load/Execute/start/etcetc

Code:
public static void StartServer()
        {
                QuizShowInfo[(byte)1] = "Dany";
                QuizShowInfo[(ushort)1] = 245;
                QuizShowInfo[1] = 100;
                QuizShowInfo[(byte)2] = "Lord";
                QuizShowInfo[(ushort)2] = 244;
                QuizShowInfo[2] = 200;
                QuizShowInfo[(byte)3] = "Quiz-Master";
                QuizShowInfo[(ushort)3] = 243;
                QuizShowInfo[3] = 400;
                GenerateKey();
                Struct.LoadItems("items.txt");
                Struct.LoadItemPluses("itemadd.ini");
                Struct.LoadMaps();
                Struct.LoadMonsters();
                Struct.LoadNpcs();
                Struct.LoadPortals();
                Struct.LoadServerskills();
                Struct.LoadTNpcs();
                Struct.LoadFeatures();
                Struct.LoadGuilds();
                Database.Database.LoadRevivePoints();
                Database.Database.LoadEnchantData();
                Database.Database.LoadTops();
                //Database.Database.PurgeGuilds();
                Console.WriteLine("This program is a branch of CoEmu.Nano, property of the CoEmu Foundation.");
                Console.WriteLine("[GameServer-Init] Creating Game Thread..");
                [COLOR="DarkRed"]Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();[/COLOR]
                Console.WriteLine("[GameServer-Init](Game Thread) Success.");
                Console.WriteLine("[GameServer-Init] Creating Auth Thread..");
                [COLOR="DarkRed"]Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();[/COLOR]
                Console.WriteLine("[GameServer-Init](Auth Thread) Success.");
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                SummonedGuardsThread = new CoEmuThread(); SummonedGuardsThread.Start(SummonedGuardsCheck);
                GuardsThread = new CoEmuThread(); GuardsThread.Start(GuardsCheck);
                BroadCastTimer = DateTime.Now;
                RandEventTimer = DateTime.Now;
                PkTournyStarTime = DateTime.Now;
                TradePartnerCount = DateTime.Now;
                LastMobsMove = DateTime.Now;
                LastDMapCheck = DateTime.Now;
                CheckWalk = DateTime.Now;
                GuildScores = DateTime.Now;
                LastUpdateSite = DateTime.Now;
                LastGuildPoints = DateTime.Now;
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
make sure you dident change any of the server connection setting else when you start the server and that exception pup up it wold be high lighted so you can see it follow that high lighted line by one clicking each colored
Quote:
example
Nano.GameServer = new MasterSocket("GameServer");
new Thread(Nano.GameServer.AcceptNewConnections).Start ();
part and hit F12 that well take you to the definition for each void you have there make sure they are all fine and nothing has changed else idk :P
10/10/2010 01:25 killersub#3
Quote:
Originally Posted by { Angelius } View Post
your Problem is in Accepting a New Connection



make sure you dident change any of the server connection setting else when you start the server and that exception pup up it wold be high lighted so you can see it follow that high lighted line by one clicking each colored part and hit F12 that well take you to the definition for each void you have there make sure they are all fine and nothing has changed else idk :P
nah bra...I tried it but it still gives me that same shitty error >.<
10/10/2010 01:29 { Angelius }#4
can you post the line only the highlighted line ?
10/10/2010 01:31 killersub#5
Quote:
Originally Posted by { Angelius } View Post
can you post the line only the highlighted line ?
this is the highlighted line it goes straight to, once it starts up.

Code:
Nano.StartServer();
it's in yellow color btw...
10/10/2010 01:41 { Angelius }#6
idk what did you edit but the start server part must go Through those lines so try to replace it with this one and let me know

Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                BroadCastTimer = DateTime.Now;
                RandEventTimer = DateTime.Now;
                PkTournyStarTime = DateTime.Now;
                TradePartnerCount = DateTime.Now;
                LastMobsMove = DateTime.Now;
                LastDMapCheck = DateTime.Now;
                CheckWalk = DateTime.Now;
                GuildScores = DateTime.Now;
                LastUpdateSite = DateTime.Now;
                LastGuildPoints = DateTime.Now;
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
after that try this one

Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
this way you can only test the connection and make sure what is the problem connection or loading good luck and let me know plz
10/10/2010 01:50 killersub#7
Quote:
Originally Posted by { Angelius } View Post
idk what did you edit but the start server part must go Through those lines so try to replace it with this one and let me know

Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                BroadCastTimer = DateTime.Now;
                RandEventTimer = DateTime.Now;
                PkTournyStarTime = DateTime.Now;
                TradePartnerCount = DateTime.Now;
                LastMobsMove = DateTime.Now;
                LastDMapCheck = DateTime.Now;
                CheckWalk = DateTime.Now;
                GuildScores = DateTime.Now;
                LastUpdateSite = DateTime.Now;
                LastGuildPoints = DateTime.Now;
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
after that try this one

Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.GameServer = new MasterSocket("GameServer");
                new Thread(Nano.GameServer.AcceptNewConnections).Start();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
this way you can only test the connection and make sure what is the problem connection or loading good luck and let me know plz
still gettin the exact same error after trying both =/
10/10/2010 01:57 { Angelius }#8
ok there is a file called sockets you can reach it by right clicking and say go to definition on where it says MasterSocket
Code:
new Thread(Nano.GameServer.AcceptNewConnections).Start();
Nano.AuthServer = new [COLOR="Red"]MasterSocket[/COLOR]("AuthServer");
once you are there you should see something like this

Code:
public class MasterSocket
    {
        protected Socket ServerSocket;
        protected const int LOGIN_PORT = 9958;
        protected const string SERVER_IP = "5.195.232.181";
        protected const string SITE_IP = "127.0.0.1";
        protected const int AUTH_PORT = 5817;
        protected const int GAME_PORT = 5816;
        protected string ServerName;
        protected static bool Continue = true;

        public [COLOR="Red"]MasterSocket[/COLOR](string name)
        {
            ServerName = name;
            if (name == "[COLOR="Red"]GameServer[/COLOR]")
            {
                ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint IPE = new IPEndPoint(new IPAddress(0), GAME_PORT);
                try
                {
                    ServerSocket.Bind(IPE);
                }
                catch (Exception EXC)
                {
                    Program.WriteLine("[" + name + "-Init] Failed, unable to bind server to socket.");
                    Program.WriteLine(EXC);
                    System.Environment.Exit(-1);
                }
            }
            else if (name == "[COLOR="Red"]AuthServer[/COLOR]")
            {
                ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint IPE = new IPEndPoint(new IPAddress(0), AUTH_PORT);
                try
                {
                    ServerSocket.Bind(IPE);
                }
                catch (Exception e)
                {
                    Program.WriteLine("[" + name + "-Init] Failed, unable to bind server to socket.");
                    Program.WriteLine(e.StackTrace);
                    System.Environment.Exit(-1);
                }
            }
        }

        public void AcceptNewConnections()
        {
            ServerSocket.Listen(100);
            while (Continue)
            {
                if (ServerName == "GameServer")
                {
                    Socket CSocket = null;
                    try
                    {
                        CSocket = ServerSocket.Accept();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine("Unable to accept a new connection, closing now.");
                        ServerSocket.Close();
                        Program.WriteLine(e.StackTrace);
                        return;
                    }
                    try
                    {
                        if (CSocket.Connected)
                        {
                            if (!CSocket.RemoteEndPoint.ToString().Contains(SITE_IP))
                            {
                                ClientSocket CS = new ClientSocket(CSocket);
                                new Thread(CS.Run).Start();
                            }
                            else
                            {
                                CSocket.Close();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (CSocket != null)
                            CSocket.Close();
                        Program.WriteLine("[GameServer] Unable to login a new client, see exception print below.");
                        Program.WriteLine(e.ToString());
                    }
                }
                if (ServerName == "AuthServer")
                {
                    Socket ASocket = null;
                    try
                    {
                        ASocket = ServerSocket.Accept();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine("Unable to accept data from Auth Server.");
                        ServerSocket.Close();
                        Program.WriteLine(e.ToString());
                        return;
                    }
                    if (ASocket != null)
                    {
                        try
                        {
                            byte[] Buffer = new byte[8092];
                            int size = ASocket.Receive(Buffer);
                            byte[] Data = new byte[size];
                            Array.Copy(Buffer, Data, size);
                            AuthHandler.HandleAuth(Data, ASocket);
                            Data = null;
                            Buffer = null;
                        }
                        catch (Exception e)
                        {
                            Program.WriteLine(e.ToString());
                        }
                    }
                }
            }
        }
        public void Close()
        {
            Program.WriteLine("[" + ServerName + "-End] Closing Socket.");
            ServerSocket.Close();
            Continue = false;
            if (ServerName == "GameServer")
            {
                World.Continue = false;
            }
        }
    }
}
and that is the problem my friend its only a connection problem check all the ip's/ports/all other connection info and that should do it
10/10/2010 02:01 killersub#9
Quote:
Originally Posted by { Angelius } View Post
ok there is a file called sockets you can reach it by right clicking and say go to definition on where it says MasterSocket
Code:
new Thread(Nano.GameServer.AcceptNewConnections).Start();
Nano.AuthServer = new [COLOR="Red"]MasterSocket[/COLOR]("AuthServer");
once you are there you should see something like this

Code:
public class MasterSocket
    {
        protected Socket ServerSocket;
        protected const int LOGIN_PORT = 9958;
        protected const string SERVER_IP = "5.195.232.181";
        protected const string SITE_IP = "127.0.0.1";
        protected const int AUTH_PORT = 5817;
        protected const int GAME_PORT = 5816;
        protected string ServerName;
        protected static bool Continue = true;

        public [COLOR="Red"]MasterSocket[/COLOR](string name)
        {
            ServerName = name;
            if (name == "[COLOR="Red"]GameServer[/COLOR]")
            {
                ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint IPE = new IPEndPoint(new IPAddress(0), GAME_PORT);
                try
                {
                    ServerSocket.Bind(IPE);
                }
                catch (Exception EXC)
                {
                    Program.WriteLine("[" + name + "-Init] Failed, unable to bind server to socket.");
                    Program.WriteLine(EXC);
                    System.Environment.Exit(-1);
                }
            }
            else if (name == "[COLOR="Red"]AuthServer[/COLOR]")
            {
                ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint IPE = new IPEndPoint(new IPAddress(0), AUTH_PORT);
                try
                {
                    ServerSocket.Bind(IPE);
                }
                catch (Exception e)
                {
                    Program.WriteLine("[" + name + "-Init] Failed, unable to bind server to socket.");
                    Program.WriteLine(e.StackTrace);
                    System.Environment.Exit(-1);
                }
            }
        }

        public void AcceptNewConnections()
        {
            ServerSocket.Listen(100);
            while (Continue)
            {
                if (ServerName == "GameServer")
                {
                    Socket CSocket = null;
                    try
                    {
                        CSocket = ServerSocket.Accept();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine("Unable to accept a new connection, closing now.");
                        ServerSocket.Close();
                        Program.WriteLine(e.StackTrace);
                        return;
                    }
                    try
                    {
                        if (CSocket.Connected)
                        {
                            if (!CSocket.RemoteEndPoint.ToString().Contains(SITE_IP))
                            {
                                ClientSocket CS = new ClientSocket(CSocket);
                                new Thread(CS.Run).Start();
                            }
                            else
                            {
                                CSocket.Close();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (CSocket != null)
                            CSocket.Close();
                        Program.WriteLine("[GameServer] Unable to login a new client, see exception print below.");
                        Program.WriteLine(e.ToString());
                    }
                }
                if (ServerName == "AuthServer")
                {
                    Socket ASocket = null;
                    try
                    {
                        ASocket = ServerSocket.Accept();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine("Unable to accept data from Auth Server.");
                        ServerSocket.Close();
                        Program.WriteLine(e.ToString());
                        return;
                    }
                    if (ASocket != null)
                    {
                        try
                        {
                            byte[] Buffer = new byte[8092];
                            int size = ASocket.Receive(Buffer);
                            byte[] Data = new byte[size];
                            Array.Copy(Buffer, Data, size);
                            AuthHandler.HandleAuth(Data, ASocket);
                            Data = null;
                            Buffer = null;
                        }
                        catch (Exception e)
                        {
                            Program.WriteLine(e.ToString());
                        }
                    }
                }
            }
        }
        public void Close()
        {
            Program.WriteLine("[" + ServerName + "-End] Closing Socket.");
            ServerSocket.Close();
            Continue = false;
            if (ServerName == "GameServer")
            {
                World.Continue = false;
            }
        }
    }
}
and that is the problem my friend its only a connection problem check all the ip's/ports/all other connection info and that should do it
so ur tellin me that my GameServer crashing is a connection problem? wtf lol.?
10/10/2010 02:05 { Angelius }#10
yep
10/10/2010 02:09 killersub#11
Quote:
Originally Posted by { Angelius } View Post
yep
impossible. that's only if you can't login to your server/login-freeze.

My GameServer crashing has something to do with the StartServer void(or something being added to it) not the MasterSocket thread lol...
10/10/2010 02:23 { Angelius }#12
this is your start server an if you dident touch it like you said before than it must work fine place this one and try to run the server
Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
10/10/2010 02:29 killersub#13
Quote:
Originally Posted by { Angelius } View Post
this is your start server an if you dident touch it like you said before than it must work fine place this one and try to run the server
Code:
public static void StartServer()
        {
                GenerateKey();
                Nano.AuthServer = new MasterSocket("AuthServer");
                new Thread(Nano.AuthServer.AcceptNewConnections).Start();
                CharacterThread = new CoEmuThread(); CharacterThread.Start(CharacterCheck);
                ServerToolsThread = new CoEmuThread(); ServerToolsThread.Start(ToolsCheck);
                ConsoleCommands();
            }
nothing there bro...
10/10/2010 02:32 { Angelius }#14
what dose that mean DID YOU GET THE SAME EXCEPTION ???
10/10/2010 02:33 killersub#15
Quote:
Originally Posted by { Angelius } View Post
what dose that mean DID YOU GET THE SAME EXCEPTION ???
calm down buddy...and yes I got the same exception.