June 20, 2013, 05:31:37 AM
Pre-Releases are now available at the PreRelease section.
If any issues occur please post exceptions or information as to how to reproduce in the correct section.

Author Topic: Client Sent Invalid Network Message (Ridiculously big number)  (Read 1220 times)

0 Members and 1 Guest are viewing this topic.

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Client Sent Invalid Network Message (Ridiculously big number)
« on: August 16, 2011, 12:22:44 PM »
As the title suggests, People keep Disconnecting from my server with numbers like (354550293) and I even had a huge negative number once before. Any one know how to fix this?

Vindicator209

  • Newbie
  • *
  • Posts: 14
  • Karma: +1/-0
    • View Profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #1 on: August 17, 2011, 01:19:04 AM »
I can second this. Players on my server are frequently disconnected by either "Server Malfunction: Please reconnect" or the problem the OP described.

Code: [Select]
System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: count
  at System.Buffer.BlockCopy (System.Array src, Int32 srcOffset, System.Array dst, Int32 dstOffset, Int32 count) [0x00000] in <filename unknown>:0
  at Terraria_Server.Networking.ClientConnection.DecodeMessages (System.Byte[] readBuffer, System.Int32& totalData, System.Int32& msgLen) [0x00000] in <filename unknown>:0
  at Terraria_Server.Networking.ClientConnection.ProcessRead () [0x00000] in <filename unknown>:0
8/16/2011 3:50:26 PM Pool> 192.168.1.4:49900 @ 0: disconnecting for: Server malfunction, please reconnect.
8/16/2011 3:50:26 PM Pool> 192.168.1.4:49900 @ 0: connection closed (ConnectionAborted).

UndeadMiner

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 88
  • Karma: +6/-1
  • Damned to dig.
    • View Profile
    • GitHub profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #2 on: August 17, 2011, 04:50:20 AM »
This is not a server problem, it's a client issue. It means the client's data stream got corrupted, is no longer valid, and the server can't do anything sensible with it. I get it a lot myself with an unpatched client under wine. (Happens when there's a lot of stuff going on.)
The difference between TDSM and other servers is simply that we specifically detect the condition, while the stock server would in most cases cease to process the client's data stream silently and let the client timeout after a minute.
I'm employed full-time now, that's why you don't see me much.
1Hb6Q13mRV2PL6nwu5XgaYDTK62BJC4MyU

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #3 on: August 17, 2011, 07:26:55 AM »
Any chance of this getting fixed... (attaching error for debugging purposes)

Code: [Select]
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.BitConverter.ToInt32(Byte[] value, Int32 startIndex)
   at Terraria_Server.Networking.ClientConnection.DecodeMessages(Byte[] readBuffer, Int32& totalData, Int32& msgLen)
   at Terraria_Server.Networking.ClientConnection.ProcessRead()

UndeadMiner

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 88
  • Karma: +6/-1
  • Damned to dig.
    • View Profile
    • GitHub profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #4 on: August 17, 2011, 08:08:01 AM »
Any chance of this getting fixed... (attaching error for debugging purposes)
More context please, post the preceding log messages, especially if there was a kick.
I'm employed full-time now, that's why you don't see me much.
1Hb6Q13mRV2PL6nwu5XgaYDTK62BJC4MyU

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #5 on: August 17, 2011, 08:43:04 AM »
Preceding posts.

Code: [Select]
17/08/2011 14:39:17 Pool> 192.168.0.111:1762 @ 1: disconnecting for: Client sent invalid network message (805324694)
17/08/2011 14:39:17 Pool> 192.168.0.111:1762 @ 1: connection closed (ConnectionAborted).
17/08/2011 14:39:17 Pool> 192.168.0.111:1762 @ 1: LEAVE Akae
17/08/2011 14:39:17 Pool> Error processing read from client 192.168.0.111:1762 @ -1:
System.ArgumentOutOfRangeException: Non-negative number required.

I keep getting this error... it's weird because I'm connecting to this Server Via Lan... so there can't be any issues with connectivity

UndeadMiner

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 88
  • Karma: +6/-1
  • Damned to dig.
    • View Profile
    • GitHub profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #6 on: August 17, 2011, 08:48:16 AM »
Like I explained previously, "Client sent invalid network message" is a client issue.
Any exceptions immediately after that are irrelevant, since they happen only after the client has already been disconnected. I plan on fixing them, since they may cause some resources to be leaked, but I can't fix "Client sent invalid network message."
I'm employed full-time now, that's why you don't see me much.
1Hb6Q13mRV2PL6nwu5XgaYDTK62BJC4MyU

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #7 on: August 17, 2011, 09:12:28 AM »
the wierd thing is, I have the latest version of Terraria ( I own it on steam ) and I connect over Gbit lan to my server, so Unless it's a problem with Terraria itself (which I don't get because I never disconnect from a stock server) and as a fellow programmer I can't understand how there'd be any way the data stream can be corrupted unless a certain variable is read "wrongly" or corrupted by the server client.

UndeadMiner

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 88
  • Karma: +6/-1
  • Damned to dig.
    • View Profile
    • GitHub profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #8 on: August 17, 2011, 09:52:46 AM »
Unless it's a problem with Terraria itself (which I don't get because I never disconnect from a stock server) and as a fellow programmer I can't understand how there'd be any way the data stream can be corrupted unless a certain variable is read "wrongly" or corrupted by the server client.
That's precisely what I meant when I said it was a "client issue". The client's sending code uses NetworkStream.BeginWrite in a racy fashion, which can lead to messages being interleaved with or partially overwritten by other messages. Since messages are encoded as <Length> <Payload>, it leads to undefined data being written as length and that's precisely the number you see in the kick message. Stock servers simply accept such length values and wait for millions of bytes before they process any further messages, which leads to timeouts.
However, the last time I verified that there was an error in the actual data stream and not my code was before the last refactoring of network code which went into b30. If you want, I can check the actual data stream in your case if you provide me with a wireshark capture of the connection between server and client.
I'm employed full-time now, that's why you don't see me much.
1Hb6Q13mRV2PL6nwu5XgaYDTK62BJC4MyU

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #9 on: August 17, 2011, 10:57:27 AM »
Here's a paste of my wireshark capture, unfortunately I can't get you the actual capture because the program crashed on me... But this is the text file of the last few seconds before my crash. (crash being pretty much at the bottom)

UndeadMiner

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 88
  • Karma: +6/-1
  • Damned to dig.
    • View Profile
    • GitHub profile
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #10 on: August 17, 2011, 11:07:27 AM »
Sorry, but that doesn't help me at all. I need to extract the actual data stream from the capture file.

EDIT: Be sure to set the capture size to at least 1500 bytes so whole packets get captured. Use a filter like "tcp port 7777" so other traffic wasn't included.
« Last Edit: August 17, 2011, 11:23:42 AM by UndeadMiner »
I'm employed full-time now, that's why you don't see me much.
1Hb6Q13mRV2PL6nwu5XgaYDTK62BJC4MyU

DrMattsuu

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
  • A trap since 1991
    • View Profile
    • KarmaAgenda
Re: Client Sent Invalid Network Message (Ridiculously big number)
« Reply #11 on: August 17, 2011, 11:43:37 AM »
Alright I'll run the capture next time I get around to playing Terraria... Thanks for your help so far.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal