Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

HTTPService Timeout

Avatar

Level 2

How do you properly handle HTTPService calls that never return with  Result or Error? I have one that repeatedly sits and sits, never coming back from the server.

If I set timeout, that's fine, but then how to gracefully tell the user the call has been timed out?

7 Replies

Avatar

Level 3

If you set requestTimeout then your request will raise a fault when it times out so you can just add an event listener to the httpservice faultevent and could display an Alert with some info for the user.

Avatar

Level 2

Is there somethign special I have to do to get the fault to raise...? Because I have a fault event defined for my service, and I set the timeout seconds, but nothing happens...???

Avatar

Level 3

Could you post how do you declare your httpservice? and how do you add the service event listener? and the event listeners as well?

Avatar

Level 2

Sure:

private

function sendID1(id:String):void

{

var params:Object = new

Object();

params.p_id=id;

httpSvcGetName1.send(params);

}

private function svcGetName1Result(evt:ResultEvent):void

{

var

resultObj:Object = evt.result;

/* Assign the values... */

//Alert.show(resultObj.toString());

lblName1.text=resultObj.toString();

}

public function svcFault1(faultEvent:FaultEvent):void

{

var

faultstring:String = faultEvent.fault.rootCause.toString();

Alert.show(faultstring,'Fault');

MXML:

<mx:HTTPService

id="

httpSvcGetName1

"

url="

http://myservice.P_GET_FULLNAME

"

showBusyCursor="

true

"

requestTimeout="

10"

resultFormat="

text

"

fault="svcFault1(event)"

result="svcGetName1Result(event)"

/>

Avatar

Level 3

Your code looks ok, have you tried debugging your app and setting breakpoints in the result and fault handlers to see if the response hit one of these?

Avatar

Level 2

Well, I did put "alerts" in the Fault handler, and it never gets called...the hourglass (clock) comes up for 10 seconds (or whatever I set the timeout to), then just simply goes away...

Avatar

Level 2

This issue still plagues me...

Only occasionaly, but it still happens that my service never responds, and just sits.

Any suggestions...

BUMP!