多线程 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
上网的各种方法都试了 都是各种问题 

解决方案 »

  1.   

    这种应该是服务端引起,如做了防CC或者并发超出服务端请求负载,被拒掉。
    循环里加上 sleep(n),n根据需要调整;
      

  2.   

    你的IP访问太频繁了,服务器端设置的,积极拒绝。
    若么调整访问频率,若么多弄一些IP把IP分散开。
      

  3.   

    你得有进程调度管理器吧
    简单思路:
    1.POST之前先向tMNG发出申请
    2.tMNG查看正在POST中线程数量,及最后的POST时间,如果时间间隔不够,返回等待状态字
    3.tMNG登记线程开始
    4.POST完成后,向tMNG发出完成信号
    5.tMNG登记线程完成
      

  4.   

    try
      IdHttp_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;