Recent

Author Topic: [Solved]Indy communicaton problem  (Read 1035 times)

@Func

  • New Member
  • *
  • Posts: 36
[Solved]Indy communicaton problem
« on: January 10, 2020, 05:10:32 am »
I have a program running in ubuntu Core. When i start it from command line type after ubuntu completly startup it work prefect fine. But if i put it in rc.local let it startup with system . It will crashed .
At first i suspect the reason is network haven't get ready . So i put ping testing command in rc.local before my program command line.  From the log i got showing the network already been loaded.
So I write some log record in indy source code , i found it dead locked in when it using readLn to read html content from server

here is the code from Idhttp.pas 's TIdCustomeHttp class
 
      ConnectToHost(Request, Response);

      // Workaround for servers wich respond with 100 Continue on GET and HEAD
      // This workaround is just for temporary use until we have final HTTP 1.1
      // realisation. HTTP 1.1 is ongoing because of all the buggy and conflicting servers.
      repeat
       
        Response.ResponseText := IOHandler.ReadLn;  ->This is the line deadLocked
        SysLog.Info(Response.ResponseText);
        FHTTPProto.RetrieveHeaders(MaxHeaderLines);
        ProcessCookies(Request, Response);
      until Response.ResponseCode <> 100;

      case FHTTPProto.ProcessResponse(AIgnoreReplies) of
        wnAuthRequest:
          begin
            Request.URL := AURL;
          end;
        wnReadAndGo:
          begin                 

And from the log files i found readln after some sub calling ,finally it stop at this function

class function TIdSocketListUnix.FDSelect(AReadSet, AWriteSet, AExceptSet: PFDSet;
  const ATimeout: Integer): Integer;
var
  LTime: TTimeVal;
  LTimePtr: PTimeVal;

begin
  if ATimeout = IdTimeoutInfinite then begin
    LTimePtr := nil;
  end else begin
    LTime.tv_sec := ATimeout div 1000;
    LTime.tv_usec := (ATimeout mod 1000) * 1000;
    LTimePtr := @LTime;
  end;
  SysLog.Info('fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr)');
  Result := fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr); ->>> this is the line really dead locked
  SysLog.Info('After  fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr):'+inttostr(Result));
end;                     

From the log below you can see the have   'fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr)  ' string loged . but no after.
................
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:400 Result := CheckIsReadable(AMSec);     
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:400 EIdConnClosedGracefully.IfFalse(HandleAllocated, RSConnectionClosedGracefully);     
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:Result := FReadSocketList.SelectRead(ATimeOut);TIdSocketListUnix Unit:IdStackUnix
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:Before  TIdSocketListUnix.SelectRead Lock
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:After  TIdSocketListUnix.SelectRead Lock
10-1-20 11:57:55 Log: {Info}:10-1-20 11:57:55:fpSelect(FD_SETSIZE, AReadSet, AWriteSet, AExceptSet, LTimePtr)

Could you give me some suggestion why the select function which work fine in console using comand line but dead locked at rc.local !

thanks a lot!
   
« Last Edit: January 10, 2020, 04:22:24 pm by @Func »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1481
    • Lebeau Software
Re: [Solved]Indy communicaton problem
« Reply #1 on: January 12, 2020, 10:01:37 pm »
What you describe implies that no data is being received.  Did you validate with a network sniffer that there is actually network traffic being transmitted?  Are you sure you have a valid TCP/SSL connection to a real HTTP/S server?  Is an HTTP/S response actually being transmitted back to your app?  To avoid your code deadlocking indefinitely, you can assign a non-infinite timeout value to the TIdHTTP.ReadTimeout property, which will ultimately get passed to fpSelect().
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

@Func

  • New Member
  • *
  • Posts: 36
Re: [Solved]Indy communicaton problem
« Reply #2 on: January 13, 2020, 01:00:41 am »
What you describe implies that no data is being received.  Did you validate with a network sniffer that there is actually network traffic being transmitted?  Are you sure you have a valid TCP/SSL connection to a real HTTP/S server?  Is an HTTP/S response actually being transmitted back to your app?  To avoid your code deadlocking indefinitely, you can assign a non-infinite timeout value to the TIdHTTP.ReadTimeout property, which will ultimately get passed to fpSelect().
You are right. It's not indy's problem ,It's my system's configuartion problem, Because in rc.local there has a command to load wifi moudle . But i have removed wifi from system . So it will get a error and rc.local crashed . I think it's because of myprogram is a child of rc.local so it's go away with his parent. And why is always at fdselect , I think it's because this function is the only function need take some time ,There other instruction is so quickly to finished,only fdselect need take some time to finish. so mostly the program breaked at this place .

Thanks a lot!

 

TinyPortal © 2005-2018