Question

I got a mxml file that launch a script on my http server through a HTTPService.send() call.

Since the script on the server side takes a LOOOONG time (it could take even more than a hour) i would like to drop the connection between my air application and server when a button is clicked.

Don't know why but calling HTTPService.disconnect() is totally useless... No tcp connection drops and script keeps on running on server side.

No HTTPService.cancel() nor set HTTPService var to null worked.

How can i drop the connection?

Thanks in advance

Was it helpful?

Solution

I'm not sure what you expect to happen, based on looking at the documentation for the two methods your referring to neither says that it will close the TCP connection, actually to the contrary they say they don't wait for or do anything with regard to the TCP connection: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html

cancel()

  • Cancels the last service invocation or an invokation with the specified ID. Even though the network operation may still continue, no result or fault event is dispatched (<-- this is what it does, stops the events for the result or fault from being dispatched).

disconnect()

  • Disconnects the service's network connection. This method does not wait for outstanding network operations to complete (doesn't state that it stops the existing network operations only that it disconnects this services network connection).

You can dig through the source to get a more concrete idea of what's going on but basically as the documentation states it's just removing the calls from a list it is storing locally to dispatch events for "active" calls which have listeners. Essentially there is no way for Flex to know what kind of service/server it's dealing with and to appropriately signal to the server to cancel whatever operation it's doing at the moment. You could write another service on the server that is specifically made for the purpose of killing off another process, so you could call cancel on the HTTPService then send another request to the server which does your kill process script (closing the open socket, stopping any pending operations, killing or restarting services if necessary), but there's no way this could be completely automated without knowledge of what the processing is server side that you want to stop from happening. Imagine if there were an open gateway for cancelling operations on a server via client code, this sounds dangerous to me.

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