2011-08-18 59 views
2

我剛開始測試一些上傳工具我已經建成並投入47項上傳,但隊列在第15或18或21項隨機停止,不知道確切原因,但選擇被稱爲太早而並非所有請求都已結束。ASINetworkQueue setQueueDidFinishSelector選擇提前結束?

我唯一特別的事情就是將最大併發請求提高到6而不是4,但是 似乎並不是一個大問題。

我配置我選擇如下:

[self.uploadQueue setDelegate: self]; 
[self.uploadQueue cancelAllOperations]; 
[self.uploadQueue setRequestDidStartSelector: @selector(uploadRequestStarted:)]; 
[self.uploadQueue setRequestDidFinishSelector:@selector(uploadRequestEnded:)]; 
[self.uploadQueue setQueueDidFinishSelector:@selector(uploadQueueEnded:)]; 
[self.uploadQueue setDownloadProgressDelegate: myProgress]; 
[self.uploadQueue showAccurateProgress]; 

這是我的日誌:

2011-08-18 12:39:03.916 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView startUpload] Num requests: 47 
2011-08-18 12:39:08.987 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #3 successfully! 
2011-08-18 12:39:09.036 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #2 successfully! 
2011-08-18 12:39:09.911 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #0 successfully! 
2011-08-18 12:39:09.913 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #5 successfully! 
2011-08-18 12:39:10.011 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #4 successfully! 
2011-08-18 12:39:12.691 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #6 successfully! 
2011-08-18 12:39:13.588 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #9 successfully! 
2011-08-18 12:39:14.205 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #8 successfully! 
2011-08-18 12:39:14.229 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #10 successfully! 
2011-08-18 12:39:15.739 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #11 successfully! 
2011-08-18 12:39:17.278 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #12 successfully! 
2011-08-18 12:39:17.894 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #13 successfully! 
2011-08-18 12:39:18.815 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #15 successfully! 
2011-08-18 12:39:18.986 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #14 successfully! 
2011-08-18 12:39:19.191 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadQueueEnded:] queue ended? 

很想聽聽你們任何建議:) 在此先感謝, 夏嘉曦。

回答

3

你試過設置setShouldCancelAllRequestsOnFailure:NO?如果任何單個請求失敗,則隊列的默認行爲是取消所有剩餘的請求。

這可能是一個請求失敗(由於某種原因)這是導致你排隊過早完成。

+2

是的,我正要張貼此。同時添加一個requestFailed選擇器和一些調試,這樣你就可以知道/爲什麼事情會失敗! – JosephH

+0

嘿,謝謝,這確實解決了它!我得到的是 錯誤域= ASIHTTPRequestErrorDomain代碼= 2「請求超時」UserInfo = 0x60ed4a0 {NSLocalizedDescription =請求超時} 在哪裏設置超時時間? ......爲了以防萬一,我應該再延長一點時間? –

+0

通過設置解決了[請求setNumberOfTimesToRetryOnTimeout:2]; 非常感謝! :) –