2012-01-11 70 views
2

我這個服務Flex HTTPService組件超時反正

<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> 

此項操作需要比平常更長的執行30秒後得到一個錯誤,所以我改變最大的執行時間爲PHP爲120秒。

通過瀏覽器請求時,即http://localhost/index.php?mod=module&op=operation

我已經檢查了故障事件對象的答案,找到這個在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

腳本正確運行是否有請求執行時間限制?

編輯:使用requetTimeout了。

感謝

回答

9

好吧,在我的工作環境(Flex SDK 4.1 - AIR 2.6)簡單地使用requestTimeout="xx"不工作,我不知道爲什麼。

但設置非常全局對象URLRequestDefaults財產,因爲我需要idleTimeout工作。

我的問題的解決方案是這種配置,在應用程序的頂部。

import flash.net.URLRequestDefaults; 

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

我相信這可以幫助某人。

+0

救星,將requestTimeout是不是爲我使用Flex 4 – Savid 2013-04-17 05:53:46

+0

救星確實工作!!!! – Dave 2013-09-18 15:05:42

0

您可以設置請求超時HTTP服務的對象,這將做什麼它在錫說,但如果你想更知道這裏是語言參考鏈接:

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

這裏是它怎麼會看在你的代碼片段用120秒的時間了一個例子:

<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> 

而且WOR請記住,如果將此屬性設置爲零或更少,則請求根本不會超時(根據語言ref)。

+0

這個'requestTimeout'屬性不像現場文檔中描述的那樣工作。我之前嘗試過,結果是一樣的,沒有任何變化。 – gustyaquino 2012-02-06 11:57:23

+0

顯然超時屬性是特定瀏覽器,使用Chrome,Firefox和IE都表現不同。我沒有做過對比測試,但它值得一看,特別是如果你可以挑選適合自己的瀏覽器,(當然這是夢想權利!)。 – Jeremy 2012-02-26 18:43:59

1

雖然它似乎假定requestTimeout不起作用。它實際上是......第一次。

第一請求後,將requestTimeout在

HTTPService.channelSet.currentChannel.requestTimeout 

設置如果必須更改超時,你會想要做它。

查看的特定問題的代碼,見AbstractOperation.getDirectChannelSet()。即使的HTTPService不同的情況下,就會從:

private static var _directChannelSet:ChannelSet; 

_directChannelSet只實例化一次,並在其上的requestTimeout只設在創作,所以即使你改變的HTTPService的將requestTimeout,它不會反映在請求中。