XML Handler Null reference exception OnLogin

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

Moderators: Lapo, Bax

shaitaaan
Posts: 11
Joined: 02 Apr 2009, 04:29
Contact:

XML Handler Null reference exception OnLogin

Postby shaitaaan » 13 Apr 2009, 08:36

When we send a login request to the SFS server, we get an exception on client side as follows. We have set debug = true.


Code: Select all

XML Handler null reference exception System.NullReferenceException: Object reference not set to an instance of an object
 at SmartFoxClientAPI.Handlers.SysHandler.HandleJoinOk (System.Xml.XmlNode xml) [0x00000]
 at SmartFoxClientAPI.Handlers.SysHandler.HandleMessage (System.Object msgObj, System.String type) [0x00000]
 at SmartFoxClientAPI.SmartFoxClient.XmlReceived (System.String msg) [0x00000]  ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object) (at Assets/Server/SF_Server.cs:188)
SF_Server:OnDebugMessage(String) (at Assets/Server/SF_Server.cs:873)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:XmlReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()


Any pointers would be helpful.

Thank you.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Apr 2009, 09:21

Hi

Can you paste me the XML that you receive on the client side?

Also - is this the standard build in login or an extension on the server side?

Best
Thomas
shaitaaan
Posts: 11
Joined: 02 Apr 2009, 04:29
Contact:

Postby shaitaaan » 13 Apr 2009, 10:02

We are sending a login request to a lobby extension(custom login), which searches an existing room or creates a new room for the user. Then a joinRoom call is made on the server side.

If we set broadcast to false in joinRoom, it works fine, but in the Unity IDE it says : Extension for the new room not found.

The xml is as follows:

Code: Select all

[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='154' /></body></msg>
===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:Send(Hashtable, String, Int32, String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketConnection(Object, EventArgs)
SmartFoxClientAPI.SmartFoxClient:ConnectThread()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [ RECEIVED ]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [ RECEIVED ]: <msg t='sys'><body action='apiOK' r='0'></body></msg>, (len: 53) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : Called Smartfox call back: True (error: < >) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnConnection(Boolean, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.SysHandler:HandleApiOK(XmlNode)
SmartFoxClientAPI.Handlers.SysHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:XmlReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : LOGGING LOGGING ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnConnection(Boolean, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.SysHandler:HandleApiOK(XmlNode)
SmartFoxClientAPI.Handlers.SysHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:XmlReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [Sending]: <msg t='sys'><body action='login' r='0'><login z='DuneBuggy'><nick><![CDATA[User8CB8A6DE005B354]]></nick><pword><![CDATA[016442141RI19TCEZHEHEHCTCHE]]></pword></login></body></msg>
===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:Send(Hashtable, String, Int32, String)
SmartFoxClientAPI.SmartFoxClient:Login(String, String, String)
SF_Server:LoginUser()
SF_Server:OnConnection(Boolean, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.SysHandler:HandleApiOK(XmlNode)
SmartFoxClientAPI.Handlers.SysHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:XmlReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [ RECEIVED ]: {"t":"xt","b":{"o":{"AH":"logOK","name":"User8CB8A6DE005B354","id":3},"r":-1}}, (len: 78) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : RESPONSE RECEIVED ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnExtensionResponse(Object, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.ExtHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:JsonReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : Command: logOK ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnExtensionResponse(Object, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.ExtHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:JsonReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : LOGIN WAS SUCCESFUL ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnExtensionResponse(Object, String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.Handlers.ExtHandler:HandleMessage(Object, String)
SmartFoxClientAPI.SmartFoxClient:JsonReceived(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [ RECEIVED ]: <msg t='sys'><body action='rmList' r='0'><rmList><rm id='1' priv='0' temp='0' game='0' ucnt='0' maxu='50' maxs='0'><n><![CDATA[Lobby]]></n></rm></rmList></body></msg>, (len: 166) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [Sending - JSON]: {"t":"xt","b":{"c":"AI","p":{"BQ":"f30c0d85-3d75-4c61-b302-f6669252c3d2","AG":0,"AI":0},"r":-1,"x":"SFS_Lobby"}}
===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:SendJson(String)
SmartFoxClientAPI.SmartFoxClient:SendXtMessage(String, String, Hashtable, String, Int32)
SmartFoxClientAPI.SmartFoxClient:SendXtMessage(String, String, Hashtable, String)
SF_Server:SendXtMessage(SmartFoxClient, String, String, Hashtable, String)
SF_Server:SendLevelStateInfo(Boolean)
UiGameLobby:InitializeLobbyFirstTime()
UiGameLobby:Start()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)

=========== SMARTFOX : [ RECEIVED ]: <msg t='sys'><body action='joinOK' r='5'><pid id='1'/><vars><var n='BQ' t='s'><![CDATA[f30c0d85-3d75-4c61-b302-f6669252c3d2]]></var><var n='AI' t='n'><![CDATA[0]]></var><var n='AG' t='n'><![CDATA[0]]></var></vars><uLs r='5'><u i='3' m='0' s='0' p='1'><n><![CDATA[User8CB8A6DE005B354]]></n><vars></vars></u></uLs></body></msg>, (len: 325) ===========
UnityEngine.Debug:Log(Object)
SF_Server:SFUnityLog(Object)
SF_Server:OnDebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:DispatchEvent(SFSEvent)
SmartFoxClientAPI.SmartFoxClient:DebugMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleMessage(String)
SmartFoxClientAPI.SmartFoxClient:HandleSocketData()
System.MulticastDelegate:invoke_void()

(Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1651)


The Unity IDE throws the null reference exception and the build crashes.
I am assuming that it's because of the exception.

Sorry for the huge post. How do we overcome this issue?
Thanks in advance.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Apr 2009, 10:35

A hard case for me to debug blindly without the server and client.

The code in the API to handle the message would throw that error if the room list has not been received on the client side prior to the join. Thats about the only thing that could be the cause.

But looking at the log it definitely seem as if you do send the room list - containing a "Lobby" room with id=1, then send "something" to your extension and then the server responds wit a joinOK to a room with id=5 - which does not exist in the client room list.

So thats my guess - you simply have not send the correct room list to the client prior to joining the room.

Hope that helps!!

Dont think I can debug it further without actualyl have server+client access, and it looks more like a problem in the server side code than the API. But I might be wrong.

I will definitely add a warning message to the API code to check for an unknown room instead of blindly trusting that the roomlist is up to date. Wont work around the root problem, but at least give a warning on the console in the future.

Let me know if that helped you along!

Best
Thomas

/Thomas
shaitaaan
Posts: 11
Joined: 02 Apr 2009, 04:29
Contact:

Postby shaitaaan » 13 Apr 2009, 14:33

Thank you Thomas.

That worked for us!!! Appreciate the timely response.
:D :D :D
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Apr 2009, 15:07

Anytime! And great that it helped :-)

Good luck!

Oh - and I added various checks in the 1.2 API that print errors on the console instead of failing with the NRE. So future problems of the same kind will be caught earlier. So has had a positive effect that you reported - thanks

/Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 25 guests