-
[RESOLVED] socket data getting lost? or sent out of order?
I'm trying to fix a bug in Flashmog. The bug is described in more detail here.
Basically what is happening is that my Flash client claims that it is calling functions that don't arrive at the server -- or they arrive, but the socket data is out of order and therefore is garbled. I've stared at the source code for hours and tried a lot of trial-and-error type stuff and added trace statements to see if I can find the problem and I'm not having any luck.
In particular, there's class I have called RPCSocket that extends the AS3 Socket class so I can serialize data structures before sending them across a socket. At one point, this RPCSocket class calls super.writeBytes and super.Flush. It is the point at which I send all data out of my client. The data is binary data in AMF3 format.
code:
public function executeRPC(serviceName:String, methodName:String, methodParams:Array):void {
if (!this.connected) {
log.write('RPCSocket.executeRPC failed. ' + methodName + ' attempted on service ' + serviceName + ' while not connected', Log.HIGH);
throw new Error('RPCSocket.executeRPC failed. ' + methodName + ' attempted on service ' + serviceName + ' while not connected.');
return;
}
var rpc:Array = new Array();
rpc[0] = serviceName;
rpc[1] = methodName;
rpc[2] = methodParams;
var serializedRPC:ByteArray = serialize(rpc);
if (!serializedRPC) {
log.write('RPCSocket.executeRPC failed. Serialization failed for method ' + methodName + ' on service ' + serviceName, Log.HIGH);
dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, 'RPCSocket.executeRPC failed. Serialization failed for method ' + methodName + ' on service ' + serviceName));
}
super.writeUnsignedInt(serializedRPC.length);
super.writeBytes(serializedRPC);
super.flush();
} // executeRPC
Can someone recommend a way for me to store without corruption, conversion, or filtering or translation of any kind *all* of the information sent across this socket? I'd like to write it to a file. I'm guessing that keep a global ByteArray var and storing the info there might work, but I'm wondering how I might get the contents of that ByteArray into a file so I can inspect it.
Also, I'm wondering if I might be able to inspect what flash actually sends out on the socket? I have a sneaking suspicion that data I supply to super.writeBytes may be sent out of order or may not actually get sent across the socket. This bug I'm talking about only seems to happen under high-stress situations when I'm sending dozens of messages per second across this one socket.
-
Since Flash is synchronous and tcp/ip guarantees that order is preserved, your data should arrive in the order you call "write". So my guess is the problem is either on the server or it's not really an out of order problem (but may look like one).
Try running a packet sniffer like WireShark and capture just the data going to the port you're interested in. This will show you exactly what gets sent.
What symptom is indicating to you that the messages are getting dropped/mangled?
-
That the problem was on the server was my guess too, but having spent a LOT of time looking at the server code and testing it, I can't find problem with the logic in it.
I'm at the point now where I'm prepared to run tcpdump/wireshark on both ends and see what the story is, but we're talking about LOTS of data in raw AMF3 format. I'm dreading having to actually dig through the binary file. We're talking 100KBytes. *sigh*
-
-
I fixed the bug. It's working brilliantly now.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|