Unexpected data type from client
Hi there,
I have created a custom operation that is expecting an array objects. Inside the array of objects should be hashtables. We're connecting to the server with a flash client.
The data is being sent as follows from Flash:
[ {id:1, name:"paul"}, {id:2, name:"jamie"} ]
On the server if I debug out the data as follows:
In the log, it gets outputted like this:
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - System.Object[]
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Data type = System.Collections.Hashtable
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = name Value = paul
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = id Value = 1
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Data type = System.Collections.Generic.Dictionary`2[System.String,System.Object]
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = name Value =
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = id Value = jamie
The first one works perfectly and as expected, the second one is all messed up where the name key is empty and the id key is returning the name value.
Any ideas?
I have created a custom operation that is expecting an array objects. Inside the array of objects should be hashtables. We're connecting to the server with a flash client.
The data is being sent as follows from Flash:
[ {id:1, name:"paul"}, {id:2, name:"jamie"} ]
On the server if I debug out the data as follows:
log.Debug(this.InventoryData.ToString()); foreach (IDictionary data in this.InventoryData) { log.Debug("Data type = " + data.GetType()); //Hashtable entry = (Hashtable)this.InventoryData[data]; foreach (string key in data.Keys) { log.Debug("Key = " + key + " Value = " + data[key]); } }
In the log, it gets outputted like this:
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - System.Object[]
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Data type = System.Collections.Hashtable
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = name Value = paul
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = id Value = 1
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Data type = System.Collections.Generic.Dictionary`2[System.String,System.Object]
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = name Value =
2011-03-04 10:38:00,337 [23] DEBUG TestApp.Operations.InventoryOperation - Key = id Value = jamie
The first one works perfectly and as expected, the second one is all messed up where the name key is empty and the id key is returning the name value.
Any ideas?
0
Comments
-
I just did a serialization test and it was fine. Maybe try sending id values as strings?
If that doesn't work we have to look into the client lib..
EDIT: that really looks weird.. hashtable and dictionary in one array0 -
No difference when they were strings.0
-
can you please set Photon.SocketServer to log debug, test again and send me the log?0
-
The log results is the same as my first post.0
-
Photon.SocketServer.Application should log something..
did you set the following on application Setup:LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
also please make sure the log4net file contains the following:<logger name="Photon.SocketServer"> <level value="DEBUG" /> </logger> <logger name="OperationData"> <level value="DEBUG" /> </logger>
0 -
2011-03-04 14:02:47,891 [21] DEBUG OperationData - OnOperationReceive - ConnID=2, data=(58 bytes) FE-7A-36-00-3A-02-00-70-00-00-02-04-81-3E-04-01-04-81-6B-09-05-01-0A-0B-01-09-6E-61-6D-65-06-09-70-61-75-6C-05-69-64-06-03-31-01-0A-01-00-06-0B-6A-61-6D-69-65-04-06-03-32-01 2011-03-04 14:02:47,903 [21] DEBUG Photon.SocketServer.Application - OnOperationReceive - ConnID=2, invocId=31286, reliable=Reliable, channelId=0, cryp=False, operation=112
Is that what you're looking for?0 -
yes, thanks.
by the way, Tobias wrote in another thread (viewtopic.php?f=5&t=461#p2092) that the client libs do not support array of hashtable so I am not sure if that applies to flash as well. Did you try a hashtable with hashtables instead?0 -
I was reading about that and I believe it was failing earlier, but we'll try a few other things in the meantime.0
-
If we change Flash to pass data like this:
{ "1": {id:"1", name:"paul"}, "2": {id:"2", name:"jamie"} }
We receive this error:2011-03-04 14:19:27,028 [21] DEBUG OperationData - OnOperationReceive - ConnID=6, data=(60 bytes) FE-6C-48-00-3C-02-00-70-00-00-02-04-81-3E-04-01-04-81-6B-0A-0B-01-03-31-0A-01-09-6E-61-6D-65-06-09-70-61-75-6C-05-69-64-06-00-01-03-32-0A-01-02-06-0B-6A-61-6D-69-65-06-06-08-01-01 2011-03-04 14:19:27,039 [21] ERROR Photon.SocketServer.ErrorHandler - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.Generic.List`1.get_Item(Int32 index) at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader.ReadObject(Object& result) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Reader.cs:line 543 at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader.Read(Amf3TypeMarker amfTypeMarker, Object& result) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Reader.cs:line 139 at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader.ReadInlineDynamicObject(Object& result) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Reader.cs:line 377 at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader.ReadObject(Object& result) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Reader.cs:line 570 at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Reader.Read(Amf3TypeMarker amfTypeMarker, Object& result) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Reader.cs:line 139 at Photon.SocketServer.Rpc.Protocols.Amf3.Amf3Protocol.TryParseOperationRequest(Byte[] data, Reliability reliability, Byte channelId, ICryptoProvider cryptoProvider, OperationRequest& operationRequest) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Rpc\Protocols\Amf3\Amf3Protocol.cs:line 728 at Photon.SocketServer.Application.PhotonHostRuntimeInterfaces.IPhotonApplication.OnOperationReceive(IPhotonPeer photonPeer, Byte[] data, Int16 invocationId, MessageReliablity reliability, Byte channelId) in c:\Dev\photon-socketserver-sdk\src\Photon.SocketServer\Application.cs:line 266
0 -
looks like the client lib is buggy...I looked at each byte that you pasted earlier and the last part is not what we expect on the server side.
Interesting that you were able to cause an exception, we have to fix that as well.0 -
To me it looks like the hashtables are buggy, you could use two string arrays to work around..0
-
Ok, we'll give that a shot today and let you know if that works.0