Clients crash and malformed XML from server bug.

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Figbox
Posts: 4
Joined: 30 Apr 2008, 18:22

Clients crash and malformed XML from server bug.

Postby Figbox » 30 Apr 2008, 18:38

Hello,

My studio is developing a game for a company that just bought a full license
for smartfoxserver pro, and we are finding the codebase very easy to understand and a breeze to network and develop with. We have run into one
significant hitch, however.

We are using Actionscript 3 and are using the flash development environment, and as of yet, we haven't needed to create an extension and are programming client side only.

We have found a bug, the likes of which I have never before seen, or thought possible, which has derailed development and we don't know whether it is something we have done wrong or if it is a bug in the server.

The reason I describe it as a bug the likes of which I have never seen is that the bug pops up periodically during our coding and has to be fixed repeatedly, and then for the mysterious part... we sometimes, while the bug is not present, change a line or two of code, compile and test, the bug comes back, then we change the same lines of code back to what they were when it was working, recompile, but the bug is still there!

Anyway, the bug occurs when one client exits from the game after creating a new room. The other clients which are connected to the game then crash with a bug which is similar to when the updateRoomList is called in the wrong order, but its then followed by a message mentioning that the client has received malformed XML, and continues to receive that same message on every attempt to communicate with the server.

Heres the error log from both clients:

Code: Select all

Crashing Client Report:

[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='154' /></body></msg>

[ RECEIVED ]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91)
[ RECEIVED ]: <msg t='sys'><body action='apiOK' r='0'></body></msg>, (len: 53)
//Great! Connected successfully!
[Sending]: <msg t='sys'><body action='login' r='0'><login z='warlordsZone'><nick><![CDATA[Username]]></nick><pword><![CDATA[]]></pword></login></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='logOK' r='0'><login n='Username' id='13' mod='0'/></body></msg>, (len: 90)
//Successfully logged in as Username
[Sending]: <msg t='sys'><body action='getRmList' r='-1'></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='rmList' r='0'><rmList><rm id='1' priv='0' temp='0' game='0' ucnt='1' maxu='99999' maxs='0'><n><![CDATA[MainRoom]]></n></rm></rmList></body></msg>, (len: 172)
//We're Getting Rooms
//Gathered Room List
[Sending]: <msg t='sys'><body action='autoJoin' r='-1'></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='1'><pid id='0'/><vars /><uLs r='1'><u i='12' m='0'><n><![CDATA[Usernam]]></n><vars></vars></u><u i='13' m='0'><n><![CDATA[Username]]></n><vars></vars></u></uLs></body></msg>, (len: 211)
[ RECEIVED ]: <msg t='sys'><body action='roomAdd' r='0'><rm id='35' priv='0' temp='1' game='0' max='2' spec='0' limbo='0'><name><![CDATA[room]]></name><vars /></rm></body></msg>, (len: 163)
[Sending]: <msg t='sys'><body action='getRmList' r='1'></body></msg>

//We have received a new room named: room0
[ RECEIVED ]: <msg t='sys'><body action='rmList' r='0'><rmList><rm id='35' priv='0' temp='1' game='0' ucnt='0' maxu='2' maxs='0'><n><![CDATA[room]]></n></rm><rm id='1' priv='0' temp='0' game='0' ucnt='2' maxu='99999' maxs='0'><n><![CDATA[MainRoom]]></n></rm></rmList></body></msg>, (len: 266)
//We're Getting Rooms, roomlist has updated.
//Gathered Room List
[ RECEIVED ]: <msg t='sys'><body action='pubMsg' r='1'><user id='12' /><txt><![CDATA[GIVE]]></txt></body></msg>, (len: 97)
// We Send a public message to the creator of room who is simultaneously in room and MainRoom, to request an object representing room they just entered.
[ RECEIVED ]: <msg t='sys'><body action='dataObj' r='1'><user id='12' /><dataObj><![CDATA[<dataObj><var n='address' t='s'>InRoom</var><obj t='a' o='contents'><var n='0' t='s'>room0</var><var n='1' t='s'>Usernam</var></obj></dataObj>]]></dataObj></body></msg>, (len: 243)
// We got an object representing room and the names of users in room0 : Usernam
// Usernam closes his client.
[ RECEIVED ]: <msg t='sys'><body action='userGone' r='1'><user id='12' /></body></msg>, (len: 72)
// Error on UserGone, but function handleUserLeaveRoom is never called
// Client no longer receives any information but userGone from server.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleUserLeaveRoom()
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::xmlReceived()
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleMessage()
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleSocketData()
[ RECEIVED ]: <msg t='sys'><body action='userGone' r='1'><user id='12' /></body></msg><msg t='sys'><body action='roomDel'><rm id='35'/></body></msg>, (len: 134)
//We for some reason recieve malformed information from the server
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::xmlReceived()
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleMessage()
   at it.gotoandplay.smartfoxserver::SmartFoxClient/::handleSocketData()

Crasher Client Report:

[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='154' /></body></msg>

[ RECEIVED ]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91)
[ RECEIVED ]: <msg t='sys'><body action='apiOK' r='0'></body></msg>, (len: 53)
//Great! Connected successfully!
[Sending]: <msg t='sys'><body action='login' r='0'><login z='warlordsZone'><nick><![CDATA[Username]]></nick><pword><![CDATA[]]></pword></login></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='logOK' r='0'><login n='Username' id='16' mod='0'/></body></msg>, (len: 90)
//Successfully logged in as Usernam
[Sending]: <msg t='sys'><body action='getRmList' r='-1'></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='rmList' r='0'><rmList><rm id='1' priv='0' temp='0' game='0' ucnt='0' maxu='99999' maxs='0'><n><![CDATA[MainRoom]]></n></rm></rmList></body></msg>, (len: 172)
//We're Getting Rooms
//Gathered Room List
[Sending]: <msg t='sys'><body action='autoJoin' r='-1'></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='1'><pid id='0'/><vars /><uLs r='1'><u i='16' m='0'><n><![CDATA[Username]]></n><vars></vars></u></uLs></body></msg>, (len: 152)
[Sending]: <msg t='sys'><body action='createRoom' r='1'><room tmp='1' gam='0' spec='0' exit='1'><name><![CDATA[room0]]></name><pwd><![CDATA[]]></pwd><max>2</max><vars></vars></room></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='roomAdd' r='0'><rm id='37' priv='0' temp='1' game='0' max='2' spec='0' limbo='0'><name><![CDATA[room0]]></name><vars /></rm></body></msg>, (len: 164)
[Sending]: <msg t='sys'><body action='getRmList' r='1'></body></msg>

// We have created room0
[Sending]: <msg t='sys'><body action='joinRoom' r='1'><room id='37' pwd='' spec='0' leave='0' old='1' /></body></msg>

[ RECEIVED ]: <msg t='sys'><body action='rmList' r='0'><rmList><rm id='1' priv='0' temp='0' game='0' ucnt='1' maxu='99999' maxs='0'><n><![CDATA[MainRoom]]></n></rm><rm id='37' priv='0' temp='1' game='0' ucnt='0' maxu='2' maxs='0'><n><![CDATA[room0]]></n></rm></rmList></body></msg>, (len: 267)
//We're Getting Rooms, the roomlist updates because of the change in room numbers.
//Gathered Room List
[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='37'><pid id='0'/><vars /><uLs r='37'><u i='16' m='0'><n><![CDATA[Username]]></n><vars></vars></u></uLs></body></msg>, (len: 154)
// we close client


We hope someone can help us, this has had our heads in a spin for a long time, and we need to continue development.

If you need our code to debug more just ask.

Thanks in Advance
Chance Wees
CEO Figbox Games
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 May 2008, 06:13

You don't need to call getRoomList() after you have created a new room, you already receiving updates about room being added or removed.

the getRoomList() will completely rewrite the whole room list and re-create the API internal objects, wasting bandwdith

Try applying these changes and let us know if the problem persists
Lapo
--
gotoAndPlay()
...addicted to flash games
flarb
Posts: 131
Joined: 15 Oct 2007, 21:07
Location: Home of the Body Bag
Contact:

Postby flarb » 09 May 2008, 06:25

Hey I just came upon this bug!!!!

Was there a solution?

I don't get it--I changed some seemingly unrelated code and all of a sudden I have a crash in handleUserLeaveRoom where the getuser call returns a null object. (Because the user is already gone most likely)
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 09 May 2008, 07:04

Flarb:
can you send us a FLA with the code that creates the problem?
Thank you.
Lapo

--

gotoAndPlay()

...addicted to flash games
flarb
Posts: 131
Joined: 15 Oct 2007, 21:07
Location: Home of the Body Bag
Contact:

Postby flarb » 09 May 2008, 18:29

Well I just fixed it. I took the code from before my change and then edited a few things and it works.

I removed a call to evt.params.room.getId() inside my userleaveroom callback that I had added once this bug showed up. Now it works. But I have no idea why.
Franck Sinatra
Posts: 1
Joined: 01 Aug 2008, 13:15

Postby Franck Sinatra » 01 Aug 2008, 13:32

Hi there...
we have the same issue here.

When one player leaves a game room and return to the lobby his opponent receive random errors...

Code: Select all

TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
   at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleUserLeaveRoom()[C:\Documents and Settings\jmartinache\Bureau\WP\MONSTER BUSTER CLUB GAME AS3\src\it\gotoandplay\smartfoxserver\handlers\SysHandler.as:349]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at it.gotoandplay.smartfoxserver.handlers::SysHandler/handleMessage()[C:\Documents and Settings\jmartinache\Bureau\WP\MONSTER BUSTER CLUB GAME AS3\src\it\gotoandplay\smartfoxserver\handlers\SysHandler.as:78]
   at it.gotoandplay.smartfoxserver::SmartFoxClient/xmlReceived()[C:\Documents and Settings\jmartinache\Bureau\WP\MONSTER BUSTER CLUB GAME AS3\src\it\gotoandplay\smartfoxserver\SmartFoxClient.as:2567]
   at it.gotoandplay.smartfoxserver::SmartFoxClient/handleMessage()[C:\Documents and Settings\jmartinache\Bureau\WP\MONSTER BUSTER CLUB GAME AS3\src\it\gotoandplay\smartfoxserver\SmartFoxClient.as:2874]
   at it.gotoandplay.smartfoxserver::SmartFoxClient/handleSocketData()[C:\Documents and Settings\jmartinache\Bureau\WP\MONSTER BUSTER CLUB GAME AS3\src\it\gotoandplay\smartfoxserver\SmartFoxClient.as:2856]



User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Aug 2008, 07:27

This is not actually the same problem.
Game rooms don't receive update about other rooms being created or destroyed, so you need to call a getRoomList() and handle it before moving back to the Lobby.

If you take a look at our game examples (i.e. "SFSTris" etc...) you can clearly see how it should be done.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 70 guests