2

Is it possible to abort a flex remoteObject call? I tried the below method but the http request is still loading in the background:

var r:RemoteObject = new RemoteObject('<myDestination>');
r.source('myClass');
r.myMethod.addEventListener(ResultEvent.RESULT, myResponse);

r.myMethod(); // lets say this method takes 5 second to call

r.channelSet.disconnectAll(); // I thought this would abort the actual HTTP request but its still running

EDIT

The thing I'm interested in is freeing up the browsers HTTP Pipeline, just like in javascript where you can use abort on the XHR.

Dennis
  • 3,448
  • 8
  • 38
  • 45

2 Answers2

4

you can try cancel() method of AbstractOperation.

r.getOperation("OperationName").cancel();

UPDATE:

This is the problem, I invoke a large call then the user leaves the view so I don't need to wait for the response anymore. Right now the http request is blocking any further requests. Got any solution for this?

you should make another operation in your server side service to stop current service. then when you need to abort the current running service, cancel the operation (on flex) then call the stop service by calling stop service from flex side.

to stop current running thread on server side, depends on what server side you used.

Community
  • 1
  • 1
ktutnik
  • 6,882
  • 1
  • 29
  • 34
1

Note that by Operation cancel it will only influence the Flex client - your responders are never going to be invoked. On the server side there the request is running normally (consuming resources until the end), and you'll have to write some custom code in order to prevent that.

Cornel Creanga
  • 5,311
  • 1
  • 22
  • 28
  • This is the problem, I invoke a large call then the user leaves the view so I don't need to wait for the response anymore. Right now the http request is blocking any further requests. Got any solution for this? – Dennis Apr 11 '11 at 19:35
  • On the server side your request is executed on a thread by the application server, and it should not block any other requests (which are executed on different threads). It can block other requests if it takes a huge amount of CPU (I do not think that's the case on a multicore CPU) or because it takes some exclusive locks on another resources (like database tables, files etc). What's happening in your case? There are solutions but not generic ones, they depend on your specific use cases. What are you doing in your request, on the server side? – Cornel Creanga Apr 12 '11 at 07:22
  • I think I misunderstood you, the browser HTTP Pipelining is blocked. – Dennis Apr 12 '11 at 08:02