Giter Site home page Giter Site logo

Comments (6)

SadPencil avatar SadPencil commented on June 12, 2024 1

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.

from xna-cncnet-client.

Metadorius avatar Metadorius commented on June 12, 2024 1
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 

from xna-cncnet-client.

SadPencil avatar SadPencil commented on June 12, 2024 1
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)
             {

from xna-cncnet-client.

pzhlkj6612 avatar pzhlkj6612 commented on June 12, 2024

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);

from xna-cncnet-client.

SadPencil avatar SadPencil commented on June 12, 2024
        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);

from xna-cncnet-client.

SadPencil avatar SadPencil commented on June 12, 2024

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

from xna-cncnet-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.