多執行緒 post 10054 connection reset by peer 經常出這個或 read timed out 這個怎么破呀 無奈 呀
while not Terminated do
begin
try
try
if IdHttp_A.Connected then IdHttp_A.Disconnect;
if not IdHttp_A.Connected then
IdHttp_A:=TIdHTTP.Create(nil);
ResponseStr:=IdHttp_A.Post(formatString,tmp_string);
except
on e : Exception do
begin
showmessage()
end
end
finally
IdHttp_A.Disconnect;
IdHttp.Free;
end
上網的各種方法都試了 都是各種問題
uj5u.com熱心網友回復:
這種應該是服務端引起,如做了防CC或者并發超出服務端請求負載,被拒掉。回圈里加上 sleep(n),n根據需要調整;
uj5u.com熱心網友回復:
你的IP訪問太頻繁了,服務器端設定的,積極拒絕。若么調整訪問頻率,若么多弄一些IP把IP分散開。
uj5u.com熱心網友回復:
你得有行程調度管理器吧簡單思路:
1.POST之前先向tMNG發出申請
2.tMNG查看正在POST中執行緒數量,及最后的POST時間,如果時間間隔不夠,回傳等待狀態字
3.tMNG登記執行緒開始
4.POST完成后,向tMNG發出完成信號
5.tMNG登記執行緒完成
uj5u.com熱心網友回復:
tryIdHttp_A := TIdHTTP.Create(nil);
idHttp_A.HandleRedirects := True;
idHttp_A.ConnectTimeout := 3000;
// 引數設定...
while not Terminated do
try
if IdHttp_A.Connected then IdHttp_A.Disconnect;
Sleep(100);
ResponseStr := IdHttp_A.Post(formatString, tmp_string);
// ...
except
Raise;
// ...
end;
finally
if Assigned(IdHttp_A) then IdHttp_A.Free;
end;
uj5u.com熱心網友回復:
10054 ,被服務器端踢了,要調整訪問策略。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/31010.html
標籤:網絡通信/分布式開發
