Flex HTTPService times out anyway

2019-01-28 12:38发布

问题:

I'm getting an error after 30 seconds of execution of this service

<s:HTTPService id="svcList" url="http://localhost/index.php" method="GET" result="svcList_resultHandler(event)" fault="svcList_faultHandler(event)" requestTimeout="300">
    <s:request xmlns="">
        <mod>module</mod>
        <op>operation</op>
    </s:request>
</s:HTTPService>

This operation takes longer than usual so I changed the max execution time for php to 120 seconds.

The script runs correctly when is requested through a browser i.e http://localhost/index.php?mod=module&op=operation

I've already checked the fault event object for an answer and find this at faultDetails Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost/index.php" errorID=2032]. URL: http://localhost/index.php

Is there a execution time limit for requests ?

Edit: Using requetTimeout already.

Thanks

回答1:

Ok, in my working environment (Flex SDK 4.1 - AIR 2.6) simply using requestTimeout="xx" doesn't work I don't know why.

But setting a very global object URLRequestDefaults property idleTimeout works as I need.

The solution for my proble is this configuration, at the top of the application.

import flash.net.URLRequestDefaults;

URLRequestDefaults.idleTimeout = 120000; //note this value represents milliseconds (120 secs)

I believe this could help somebody.



回答2:

Though it seems to be assumed that requestTimeout doesn't work. It actually does... the 1st time.

After the 1st request, the requestTimeout is set in

HTTPService.channelSet.currentChannel.requestTimeout

If you have to change the timeout, you will want to do it there.

To see the specific offending code, see AbstractOperation.getDirectChannelSet(). Even for different instances of HTTPService, it pulls from:

private static var _directChannelSet:ChannelSet;

_directChannelSet is only instantiated once, and the requestTimeout on it is only set on creation, so even if you change the requestTimeout on HTTPService, it won't reflect in the request.



回答3:

You can set the request time out of http service objects, this will do what it says on the tin, but if you want to know more here is a link for the language reference:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html#requestTimeout

Here is an example of how it could look in your code snippet with a 120 second time out:

<s:HTTPService id="svcList" requestTimeout="120" url="http://localhost/index.php" method="GET" result="svcList_resultHandler(event)" fault="svcList_faultHandler(event)">
  <s:request xmlns="">
    <mod>module</mod>
    <op>operation</op>
  </s:request>
</s:HTTPService>

Also worth bearing in mind if you set this attribute to zero or less, the request will not time out at all (according to the language ref).