Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to GameSurge not working for some #481

Open
GrantBartlett opened this issue Jul 11, 2023 · 6 comments
Open

Connection to GameSurge not working for some #481

GrantBartlett opened this issue Jul 11, 2023 · 6 comments

Comments

@GrantBartlett
Copy link
Member

Problem:

Some players from the RotE client are experiencing connection issues to GameSurge. They did not have this issue with the client before Net7 changes.

Client logs supplied from latest client:

Previous client.log working in cliente before all NET7 changes:

@SadPencil
Copy link
Member

This exception is most likely raised by string.Substring method in Connection.cs file. https://stackoverflow.com/questions/5633661/length-cannot-be-less-than-zero-on-a-blank-line

Need to attach a debugger and observe which command raises the exception.

@pzhlkj6612
Copy link
Contributor

Need to attach a debugger and observe which command raises the exception.

+1.

Printing stacktrace might be also helpful:

Logger.Log("Unable to connect to the server. " + ex.Message);

- Logger.Log("Unable to connect to the server. " + ex.Message);
+ Logger.Log("Unable to connect to the server. " + ex.Message + "\n" + ex.StackTrace);

@Metadorius
Copy link
Member

21.07. 15:37:15.632    Unable to connect to the server. Length cannot be less than zero. (Parameter 'length')
   at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex, Int32 length)
at DTAClient.Online.Connection.HandleMessage(String message) in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 515
   at DTAClient.Online.Connection.HandleComm() in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 276
   at DTAClient.Online.Connection.ConnectToServer() in C:\Users\p\Desktop\CNCNET CLIENT STUFF\xna-cncnet-client\DXMainClient\Online\Connection.cs:line 204 

@SadPencil
Copy link
Member

        private void HandleMessage(string message)
        {
            string msg = overMessage + message;
            overMessage = "";
            while (true)
            {
                int commandEndIndex = msg.IndexOf("\n");
                if (commandEndIndex == -1) whatever;
                else if (msg.Length != commandEndIndex + 1)
                {
                    // throw exception here? so commandEndIndex is 0?
                    string command = msg.Substring(0, commandEndIndex - 1);

@SadPencil
Copy link
Member

Seems like HandleMessage(message) would fail when message ends up with "\n"

@SadPencil
Copy link
Member

diff --git a/DXMainClient/Online/Connection.cs b/DXMainClient/Online/Connection.cs
index ba1341ba..f8e8c570 100644
--- a/DXMainClient/Online/Connection.cs
+++ b/DXMainClient/Online/Connection.cs
@@ -499,7 +499,7 @@ namespace DTAClient.Online
         /// <param name="message">The message.</param>
         private void HandleMessage(string message)
         {
-            string msg = overMessage + message;
+            string msg = overMessage + message.Trim();
             overMessage = "";
             while (true)
             {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

4 participants