User Variables Update Message From Server Corrupted?

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

dlong
Posts: 26
Joined: 05 May 2009, 02:46
Location: Los Angeles, CA

User Variables Update Message From Server Corrupted?

Postby dlong » 12 Aug 2009, 20:24

Hi,

Not sure what exactly is going on but in our production environment we're getting what looks to be malformed xml data back from the server in the UpdateUserVariables calls. I've included a snip from the log file below. Note this is an intermittent issue, but when it occurs, it causes the .Net library to disconnect from the server.

Code: Select all

SmartFoxMMOClient> Debug - 08/12/2009 12:37:01: [ RECEIVED ]: <msg t='sys'><body action='uVarsUpdate' r='17'><user id='14570' /><vars><var n='P' t='s'><![CDATA[-129.82,4.50,96.27]]></var><var n='R' t='s'><![CDATA[222]]></var></vars></body></msg>='uVarsUpdate' r='17'><user id='15158' /><vars><var n='P' t='s'><![CDATA[-65.71,-5.98,-27.17]]></var><var n='F' t='s'><![CDATA[00000005]]></var></vars></body></msg>, (len: 347)...

SmartFoxMMOClient> Debug - 08/12/2009 12:37:01: Disconnect due to: Text node cannot appear in this state.  Line 1, position 184....
SmartFoxMMOClient> ConnectionLost - 08/12/2009 12:37:01: connection was lost...
MMO: Error Connection was lost.
UnityEngine.Debug:Log(Object)
UtDebug:LogError(Object, Int32) (at Assets/PlugIns/Scripts/UtUtilities/UtDebug.cs:47)
MMOClient:Error(Object, MMOErrorEventArgs) (at Assets/zzCommon/Scripts/MMO/MMOClient.cs:446)
Multiplayer.SmartFox.SmartFoxMMOClient:OnError(MMOErrorEventArgs)
Multiplayer.SmartFox.SmartFoxMMOClient:OnConnectionLost()
SmartFoxClientAPI.SmartFoxClient:_DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:HandleSocketDisconnection()
SmartFoxClientAPI.SmartFoxClient:Disconnect()
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()


You can see in the data that is received that the error is about midway through the data at "</msg>='uVarsUpdate' r='17'>" where one msg is closed with the </msg> tag and for some reason the beginning of the next message is not properly started.

Now, I'm not super familiar with SFS but it looks like the server is sending back bad data that the client cannot handle. It appears that this occurs when multiple messages are packaged together at the server level and sent out as one to the client. This occurs right after I connect, login, and join a room. This is standard user variable update logic... nothing tricky going on here.

I'm using the new 1.2.2 .Net Smart Fox Client library with Unity and SFS version 1.6.6 with an unlimited license.

Any advice, places to look, config file settings, etc would be greatly appreciated.

Thanks!

DL


System Info from server log file:

Code: Select all

INFO   | jvm 1    | 2009/08/12 01:44:06 | --- [ System Info ] ------------------------------------------
INFO   | jvm 1    | 2009/08/12 01:44:06 |
INFO   | jvm 1    | 2009/08/12 01:44:06 | System CPU(s): 8
INFO   | jvm 1    | 2009/08/12 01:44:06 | VM Max memory: 3817 MB
INFO   | jvm 1    | 2009/08/12 01:44:06 |
INFO   | jvm 1    | 2009/08/12 01:44:06 | os.name: Windows Server 2008
INFO   | jvm 1    | 2009/08/12 01:44:06 | os.arch: amd64
INFO   | jvm 1    | 2009/08/12 01:44:06 | os.version: 6.0
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.version: 1.6.0_13
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vendor: Sun Microsystems Inc.
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vendor.url: http://java.sun.com/
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vm.specification.version: 1.0
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vm.version: 11.3-b02
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vm.vendor: Sun Microsystems Inc.
INFO   | jvm 1    | 2009/08/12 01:44:06 | java.vm.name: Java HotSpot(TM) 64-Bit Server VM
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Aug 2009, 11:13

Hi!

Did you also get this behaviour in 1.2.1? Changed the socket code for 1.2.2 to cut it up differently for unicode support, so want to narrow down the problem if the new code introduced this or not.

Thanks

/T
dlong
Posts: 26
Joined: 05 May 2009, 02:46
Location: Los Angeles, CA

Postby dlong » 13 Aug 2009, 21:40

Hey Thomas,

So we tried it out today with two versions, one using 1.2.1 and 1.2.2. It does appear to be an issue with the 1.2.2 library. We had no problems today (or previously) with the 1.2.1 libraries in this capacity, however we were unable to connect once the number of users in a room passes some threshold. It looks like this error was also happening on the RoomList coming back when joining a room as well.

Hope this info helps... let me know if you need any more info or sample data for working on the library.

Best,

DL
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Aug 2009, 09:08

Hey DL

Thanks for testing and reporting - we got a repro case in our own game too, so we are on it.

Expect a fix "soon"

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Aug 2009, 11:43

And here is the bugfix - totally and utterly a genuine bug. I owe beer.

While Marco prepares a 1.2.3 release, the fix is in SmartFoxClient.cs

Replace the old SplitBufferMessages() with this one:

Code: Select all

      private ArrayList SplitBufferMessages() {
         ArrayList res = new ArrayList();
            
         int i=0;
         byte [] temp_buf = new byte[messageBuffer.Length];
         int temp_i = 0;
         while (i<messageBuffer.Length) {
            if (messageBuffer[i]!=0) {
               temp_buf[temp_i] = messageBuffer[i];
               temp_i++;
            }
            else {
               byte[] buf = new byte[temp_i];
               Buffer.BlockCopy(temp_buf, 0, buf, 0, temp_i);
               res.Add(buf);
               temp_buf = new byte[messageBuffer.Length];
               temp_i = 0;
               
               if (i==messageBuffer.Length-1) {
                  res.Add(new byte[0]);
               }
            }
                i++;
            }

            if (temp_i > 0) {
                byte[] buf = new byte[temp_i];
                Buffer.BlockCopy(temp_buf, 0, buf, 0, temp_i);
                res.Add(buf);
            }
            return res;
        }


/Thomas
dlong
Posts: 26
Joined: 05 May 2009, 02:46
Location: Los Angeles, CA

Postby dlong » 14 Aug 2009, 17:20

LOL, thank for the help Thomas! Glad we could assist. For now, we're going to try sticking with the 1.2.1 library until 1.2.3 comes out.

I'll let you know if I'm in Sweden and you do the same if you're in LA so we can take you up on that beer! :wink:
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 14 Aug 2009, 19:22

If you or anyone else wants a dll to test with (the one send to Marco as 1.2.3 dll), then PM me and I'll ship it to you.

Best
Thomasw

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 18 guests