Question

I'm having trouble connecting (via the Socket and XMLSocket classes) to a TCP listener after a connect timeout.

I have a flash applet that needs to maintain a TCP connection to a server. I have implemented timeouts using Timers, a ping-pong system, etc. However, there's a problem. Upon calling Socket.connect(), the flash player (9.0.115 and many other stables before that) sends 3 connection requests by way of SYN packets, with some time in between. If none of those are replied to (e.g. because the server is down), I cannot get the applet to [attempt to] connect to the server. Ever. That is, within the lifetime of the applet.

To clarify and/or summarize:

For any host/port pair given to Socket.connect() or XMLSocket.connect(), if the call fails, any subsequent connect() calls to any other Socket (or XMLSocket) instances within the lifetime of the Flash applet to the same host/port pair get ignored. (At least as far as I can tell using a packet sniffer.)

I have tried calling numerous Socket methods, destroying¹ and recreating the objects, using a pool of Sockets, and various other methods I can't remember right now; all to no avail.

My current solution is to notify the parent webpage through a JavaScript call and let it reload my applet. It's not a pretty solution, and I'm not about to implement workarounds for the problems it causes, just because Flash can't handle socket connections properly.

I must be missing something very simple.

Any ideas?

1: I know you can't really destroy objects; I just remove all references to them and hope for the best. I haven't tried to explicitly invoke the GC in this case. (Though I think I did try putting the Socket inside an Array and using delete.)


Yes, it works as expected if the connection is successful (even if the connection drops later on.)

The only event to trigger this is the case when the server doesn't respond at all; it's as if Flash marks the host/port combination as "offline" and doesn't bother sending any more packets to it for the lifetime of the applet.

I suspect an active refusal of the connection (e.g. host is online but not listening to the port) doesn't cause this.

I get no error message or feedback of any other kind from the Socket.

Have you ever called connect() more than once to the same host/port pair, when the first one failed? How did you know the first connect() failed? And before subsequent connect() calls, did you do anything to reset the socket?

Was it helpful?

Solution

This could be related to the unresolved bug FP-269 which in turn may have the same root cause as FP-67.

This build should be fixed in the current public beta release found on labs.adobe.com

Edwin Wong - [09/23/08 04:49 PM ]

I'd recommend you give the latest public beta a shot...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top