Re: Apache server returns early before process is complete

Andreas Mock <[email protected]> Tue, 13 May 2025 17:49:04 +0200
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------t57e8G59J1Tzt2FhU00f58jn
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Hallo Joe,

try to reduce the problem.

Make the call to your SFTP-Service via curl or some other http(s) client=
=20
to see whether you get the same timeout. If yes, than the server side is=
=20
closing the connection. If not then you have to investigate the=20
LWP::UserAgent part.

Another hint in combination with SSL:=20
https://stackoverflow.com/questions/9400068/make-timeout-work-for-lwpusera=
gent-https

Best regards
Andreas


Am 13.05.2025 um 17:22 schrieb Joseph He:
> Andreas, thank you.
>
> On the client side, I set the timeout at LWP::UserAgent request to=20
> 600, and I can verify that it indeed works on my QA and DEV=20
> environment. If I change=C2=A0it to 120, then it can timeout at 120.
> So on my production=C2=A0server, the client=C2=A0side receives a timeout=
 from=20
> the server after 5 minutes, so I still think the server Timeout plays=20
> a role here. I just don't know what config I can change to test it out.
>
> Joe
>
> On Tue, May 13, 2025 at 10:07=E2=80=AFAM Andreas Mock <andreas.mock@web.=
de> wrote:
>
>     Hi Joe,
>
>     when you send a request via LWP::UserAgent to the Server which
>     does the long lasting SFTP calls, then I'm pretty sure that you
>     get a timout in the LWP::UserAgent code.
>
>     I'm pretty sure the client (LWP::UserAgent) is not waiting long
>     enough for the answer: https://metacpan.org/pod/LWP::UserAgent#timeo=
ut
>
>     After having here a long timeout you have to be sure that the very
>     first client which sent the very first request also waits long
>     enough to let the application server make severals tries,
>     therefore n * timeout.
>
>     Best wishes
>     Andreas
>
>
>     Am 13.05.2025 um 16:46 schrieb Joseph He:
>>     Many thanks to you all.
>>
>>     I am still trying to figure out the issue. Let me re-explain the
>>     problem I experienced with some details.
>>
>>     The environment is=C2=A0Ubuntu 22.04, Apache2,=C2=A0ModPerl.
>>     I run a Http::request with LWP::UserAgent, the server receives
>>     the request and starts to process it.
>>     But it takes much longer due=C2=A0to a stalled SFTP call to the rem=
ote
>>     server, the Apache server timeout and sends back failure,
>>     meanwhile,*the server actually=C2=A0is still trying to process this
>>     request*.
>>     On the calling side, after receiving the failure status, it
>>     initiates another http::request=C2=A0and the load balancer redirect=
s
>>     this call to another server for processing.
>>     It turns out this same http::request is processed twice.
>>
>>     On my production=C2=A0server the timeout happens at 300 seconds mar=
k.
>>     On my QA and Dev server, the timeout happens at 600 seconds. I
>>     have not changed anything on my production server yet.
>>     But on my QA and DEV servers, I have tried to change Timeout in
>>     apache2.conf, have tried to add Timeout to the virtualhost
>>     config, also have tried to add SetPerlEnv MOD_PERL_TIMEOUT to the
>>     virtualhost config, none of them change the timeout behavior of
>>     my QA and DEV servers.
>>
>>     So what exactly controls the Timeout? I am totally lost.
>>
>>     Cheers,
>>     Joe
>>
>>
>>     On Wed, Apr 23, 2025 at 5:17=E2=80=AFPM Mithun Bhattacharya
>>     <[email protected]> wrote:
>>
>>         Okay agreed that is a valid time out basically it is saying
>>         that a client has established tcp/ip connection but has not
>>         put its request either a get put or a post
>>
>>         On Wed, Apr 23, 2025, 3:38=E2=80=AFPM Joseph He
>>         <[email protected]> wrote:
>>
>>             On Apache2 doc, I found this. How does this timeout work?
>>             It looks like it can only wait for 300 seconds before
>>             failing a request.
>>
>>             https://httpd.apache.org/docs/2.0/mod/core.html#timeout
>>             Description:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Description>
>>             	Amount of time the server will wait for certain events
>>             before failing a request
>>             Syntax:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Syntax>
>>             	|TimeOut seconds|
>>             Default:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Default>
>>             	|TimeOut 300|
>>             Context:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Context>
>>             	server config, virtual host
>>             Status:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Status>
>>             	Core
>>             Module:
>>             <https://httpd.apache.org/docs/2.0/mod/directive-dict.html#=
Module>
>>             	core
>>
>>             The |TimeOut|=C2=A0directive currently defines the amount o=
f
>>             time Apache will wait for three things:
>>
>>              1. The total amount of time it takes to receive a GET
>>                 request.
>>              2. The amount of time between receipt of TCP packets on
>>                 a POST or PUT request.
>>              3. The amount of time between ACKs on transmissions of
>>                 TCP packets in responses.
>>
>>             We plan on making these separately configurable at some
>>             point down the road. The timer used to default to 1200
>>             before 1.2, but has been lowered to 300 which is still
>>             far more than necessary in most situations. It is not set
>>             any lower by default because there may still be odd
>>             places in the code where the timer is not reset when a
>>             packet is sent.
>>
>>
>>             On Wed, Apr 23, 2025 at 3:07=E2=80=AFPM Mithun Bhattacharya
>>             <[email protected]> wrote:
>>
>>                 You configure timeout at the client side. Apache is
>>                 at the server side. Server doesn't have a concept of
>>                 time it could take days to run and not care.
>>
>>                 mod_perl code is where you are sending the http
>>                 return status to make sure the client doesn't timeout
>>                 waiting for the server to respond.
>>
>>
>>                 On Wed, Apr 23, 2025, 2:19=E2=80=AFPM Joseph He
>>                 <[email protected]> wrote:
>>
>>                     Thanks, all.
>>                     Is that Apache timeout controlled by its
>>                     configuration=C2=A0"Timeout"?
>>                     I don't think it has anything to do with modPerl.
>>                     Am I=C2=A0missing something?
>>                     Thanks.
>>
>>                     On Wed, Apr 23, 2025 at 1:41=E2=80=AFPM Mithun
>>                     Bhattacharya <[email protected]> wrote:
>>
>>                         Timeout happens because of how we handle the
>>                         request. Timeout is basically no response
>>                         came back. Why that happens is because we
>>                         think we want to have a correct response.
>>                         Unfortunately for long running requests the
>>                         correct response shouldn't be via http
>>                         response code or we face situations like
>>                         this. Instead reply with a 200 OK immediately
>>                         and then provide correct status in the
>>                         message body. Once a response code/header has
>>                         been sent timeout won't trigger and you could
>>                         potentially hold the connection for hours
>>                         without a problem.
>>
>>                         On Wed, Apr 23, 2025, 9:32=E2=80=AFAM Andreas M=
ock
>>                         <[email protected]> wrote:
>>
>>                             Hi Joseph,
>>
>>                             your description is very vague, so can
>>                             only answer on some assumptions:
>>
>>                             It sounds like a timeout is fired somewhere=
.
>>
>>                             Best advice in these situations: Log as
>>                             many steps as you can. Keep your
>>                             eyes open on TCP/IP and higher level
>>                             timeouts.
>>
>>                             Declare only ONE instance responsible for
>>                             a retry: Either the app server
>>                             calling the dispatcher with several tries
>>                             or the dispatcher trying for
>>                             himself. Not both.
>>
>>                             Best regards
>>                             Andreas
>>
>>
>>                             Am 23.04.2025 um 16:21 schrieb Joseph He:
>>                             > All, good day.
>>                             >
>>                             > Here is the issue I have.
>>                             > My entire application is running on
>>                             ModPerl/Apache environment.
>>                             > I send Http::Request with data load
>>                             from my App server to a dispatch
>>                             > server thru LWP::UserAgent, I set the
>>                             timeout 600 seconds.
>>                             >
>>                             > The dispatch server is supposed to
>>                             manipulate the data and send the
>>                             > data to an external SFTP server.
>>                             Because the SFTP can fail, it will
>>                             > keep trying up to 4 times with 30
>>                             seconds sleep in case that SFTP
>>                             > connection fails.
>>                             >
>>                             > Recently, I found that I uploaded the
>>                             file twice sometimes. I figured
>>                             > out the root cause is that my Dispatch
>>                             server returns 'failure' at 6
>>                             > minutes while it keeps trying to do the
>>                             SFTP. The App server
>>                             > received=C2=A0HTTP::Response with error
>>                             status so it issued another call to
>>                             > send data. It turns out I uploaded the
>>                             identified file twice.
>>                             >
>>                             > Anybody has this sort of experience?
>>                             Why does the dispatch=C2=A0server
>>                             > return 'error' while it still processes
>>                             the data?
>>                             >
>>                             > Thanks a lot,
>>                             > Joseph
>>                             >
>>

--------------t57e8G59J1Tzt2FhU00f58jn
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-=
8">
  </head>
  <body>
    <p>Hallo Joe,</p>
    <p>try to reduce the problem.</p>
    <p>Make the call to your SFTP-Service via curl or some other http(s)
      client to see whether you get the same timeout. If yes, than the
      server side is closing the connection. If not then you have to
      investigate the LWP::UserAgent part.</p>
    <p>Another hint in combination with SSL:
<a class=3D"moz-txt-link-freetext" href=3D"https://stackoverflow.com/quest=
ions/9400068/make-timeout-work-for-lwpuseragent-https">https://stackoverfl=
ow.com/questions/9400068/make-timeout-work-for-lwpuseragent-https</a></p>
    <p>Best regards<br>
      Andreas</p>
    <p><br>
    </p>
    <div class=3D"moz-cite-prefix">Am 13.05.2025 um 17:22 schrieb Joseph
      He:<br>
    </div>
    <blockquote type=3D"cite"
cite=3D"mid:[email protected]=
il.com">
      <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUT=
F-8">
      <div dir=3D"ltr">Andreas, thank you.
        <div><br>
          <div>On the client side, I set the timeout at LWP::UserAgent
            request to 600, and I can verify that it indeed works on my
            QA and DEV environment. If I change=C2=A0it to 120, then it ca=
n
            timeout at 120.</div>
          <div>So on my production=C2=A0server, the client=C2=A0side recei=
ves a
            timeout from the server after 5 minutes, so I still think
            the server Timeout plays a role here. I just don't know what
            config I can change to test it out.</div>
          <div><br>
          </div>
          <div>Joe</div>
        </div>
      </div>
      <br>
      <div class=3D"gmail_quote gmail_quote_container">
        <div dir=3D"ltr" class=3D"gmail_attr">On Tue, May 13, 2025 at
          10:07=E2=80=AFAM Andreas Mock &lt;<a href=3D"mailto:andreas.mock=
@web.de"
            moz-do-not-send=3D"true" class=3D"moz-txt-link-freetext">andre=
[email protected]</a>&gt;
          wrote:<br>
        </div>
        <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
          <div>
            <p>Hi Joe,</p>
            <p>when you send a request via LWP::UserAgent to the Server
              which does the long lasting SFTP calls, then I'm pretty
              sure that you get a timout in the LWP::UserAgent code.</p>
            <p>I'm pretty sure the client (LWP::UserAgent) is not
              waiting long enough for the answer: <a
                href=3D"https://metacpan.org/pod/LWP::UserAgent#timeout"
                target=3D"_blank" moz-do-not-send=3D"true"
                class=3D"moz-txt-link-freetext">https://metacpan.org/pod/L=
WP::UserAgent#timeout</a></p>
            <p>After having here a long timeout you have to be sure that
              the very first client which sent the very first request
              also waits long enough to let the application server make
              severals tries, therefore n * timeout.</p>
            <p>Best wishes<br>
              Andreas</p>
            <p><br>
            </p>
            <div>Am 13.05.2025 um 16:46 schrieb Joseph He:<br>
            </div>
            <blockquote type=3D"cite">
              <div dir=3D"ltr">Many thanks to you all.
                <div><br>
                  <div>I am still trying to figure out the issue. Let me
                    re-explain the problem I experienced with some
                    details.</div>
                  <div><br>
                    The environment is=C2=A0Ubuntu 22.04, Apache2,=C2=A0Mo=
dPerl.<br>
                    I run a Http::request with LWP::UserAgent, the
                    server receives the request and starts to process
                    it.</div>
                  <div>But it takes much longer due=C2=A0to a stalled SFTP
                    call to the remote server, the Apache server timeout
                    and sends back failure, meanwhile,<b> the server
                      actually=C2=A0is still trying to process this reques=
t</b>.<br>
                    On the calling side, after receiving the failure
                    status, it initiates another http::request=C2=A0and th=
e
                    load balancer redirects this call to another server
                    for processing.=C2=A0</div>
                  <div>It turns out this same http::request is processed
                    twice.</div>
                  <div><br>
                  </div>
                  <div>On my production=C2=A0server the timeout happens at
                    300 seconds mark. On my QA and Dev server, the
                    timeout happens at 600 seconds. I have not changed
                    anything on my production server yet.=C2=A0</div>
                  <div>But on my QA and DEV servers, I have tried to
                    change Timeout in apache2.conf, have tried to add
                    Timeout to the virtualhost config, also have tried
                    to add SetPerlEnv MOD_PERL_TIMEOUT to the
                    virtualhost config, none of them change the timeout
                    behavior of my QA and DEV servers.<br>
                    <br>
                    So what exactly controls the Timeout? I am totally
                    lost.</div>
                  <div><br>
                  </div>
                  <div>Cheers,</div>
                  <div>Joe=C2=A0</div>
                  <div><br>
                  </div>
                </div>
              </div>
              <br>
              <div class=3D"gmail_quote">
                <div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr 23, 2025
                  at 5:17=E2=80=AFPM Mithun Bhattacharya &lt;<a
                    href=3D"mailto:[email protected]" target=3D"_blank"
                    moz-do-not-send=3D"true" class=3D"moz-txt-link-freetex=
t">[email protected]</a>&gt;
                  wrote:<br>
                </div>
                <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
                  <div dir=3D"auto">Okay agreed that is a valid time out
                    basically it is saying that a client has established
                    tcp/ip connection but has not put its request either
                    a get put or a post</div>
                  <br>
                  <div class=3D"gmail_quote">
                    <div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr 23,
                      2025, 3:38=E2=80=AFPM Joseph He &lt;<a
                        href=3D"mailto:[email protected]"
                        target=3D"_blank" moz-do-not-send=3D"true"
                        class=3D"moz-txt-link-freetext">joseph.he.2008@gma=
il.com</a>&gt;
                      wrote:<br>
                    </div>
                    <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
                      <div dir=3D"ltr">On Apache2 doc, I found this. How
                        does this timeout work? It looks like it can
                        only wait for 300 seconds before failing a
                        request.=C2=A0
                        <div><br>
                        </div>
                        <div><a
href=3D"https://httpd.apache.org/docs/2.0/mod/core.html#timeout"
                            rel=3D"noreferrer" target=3D"_blank"
                            moz-do-not-send=3D"true"
                            class=3D"moz-txt-link-freetext">https://httpd.=
apache.org/docs/2.0/mod/core.html#timeout</a><br>
                          <div>
                            <table
style=3D"font-size:14px;border:1px solid rgb(170,170,170);border-collapse:=
collapse;padding:2px;margin-top:0.5em;margin-bottom:1em;color:rgb(0,51,102=
)">
                              <tbody>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Descript=
ion"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Description=
:</a></th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em">Amount
                                    of time the server will wait for
                                    certain events before failing a
                                    request</td>
                                </tr>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Syntax"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Syntax:</a>=
</th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em"><code
style=3D"font-family:&quot;Courier New&quot;,Courier,monospace;font-size:1=
em">TimeOut=C2=A0<var>seconds</var></code></td>
                                </tr>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Default"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Default:</a=
></th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em"><code
style=3D"font-family:&quot;Courier New&quot;,Courier,monospace;font-size:1=
em">TimeOut
                                      300</code></td>
                                </tr>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Context"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Context:</a=
></th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em">server
                                    config, virtual host</td>
                                </tr>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Status"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Status:</a>=
</th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em">Core</td>
                                </tr>
                                <tr>
                                  <th
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;text-alig=
n:left;line-height:1.3em"><a
href=3D"https://httpd.apache.org/docs/2.0/mod/directive-dict.html#Module"
style=3D"color:rgb(0,115,199);background-color:inherit" rel=3D"noreferrer"
                                      target=3D"_blank"
                                      moz-do-not-send=3D"true">Module:</a>=
</th>
                                  <td
style=3D"empty-cells:show;padding:0.1em 0.2em;vertical-align:top;line-heig=
ht:1.3em">core</td>
                                </tr>
                              </tbody>
                            </table>
                            <p
style=3D"line-height:1.3em;margin:0px 0px 1em;padding:0px;color:rgb(0,51,1=
02);font-size:14px">The=C2=A0<code
style=3D"font-family:&quot;Courier New&quot;,Courier,monospace;font-size:1=
em;color:rgb(40,127,0);background-color:inherit">TimeOut</code>=C2=A0direc=
tive
                              currently defines the amount of time
                              Apache will wait for three things:</p>
                            <ol
                              style=3D"color:rgb(0,51,102);font-size:14px"=
>
                              <li
style=3D"line-height:1.3em;margin-top:0.5em">The total amount of time it
                                takes to receive a GET request.</li>
                              <li
style=3D"line-height:1.3em;margin-top:0.5em">The amount of time between
                                receipt of TCP packets on a POST or PUT
                                request.</li>
                              <li
style=3D"line-height:1.3em;margin-top:0.5em">The amount of time between
                                ACKs on transmissions of TCP packets in
                                responses.</li>
                            </ol>
                            <p
style=3D"line-height:1.3em;margin:0px 0px 1em;padding:0px;color:rgb(0,51,1=
02);font-size:14px">We
                              plan on making these separately
                              configurable at some point down the road.
                              The timer used to default to 1200 before
                              1.2, but has been lowered to 300 which is
                              still far more than necessary in most
                              situations. It is not set any lower by
                              default because there may still be odd
                              places in the code where the timer is not
                              reset when a packet is sent.</p>
                          </div>
                        </div>
                      </div>
                      <br>
                      <div class=3D"gmail_quote">
                        <div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr
                          23, 2025 at 3:07=E2=80=AFPM Mithun Bhattacharya =
&lt;<a
                            href=3D"mailto:[email protected]"
                            rel=3D"noreferrer" target=3D"_blank"
                            moz-do-not-send=3D"true"
                            class=3D"moz-txt-link-freetext">[email protected]=
om</a>&gt;
                          wrote:<br>
                        </div>
                        <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
                          <div dir=3D"auto">
                            <p dir=3D"ltr">You configure timeout at the
                              client side. Apache is at the server side.
                              Server doesn't have a concept of time it
                              could take days to run and not care.</p>
                            <p dir=3D"ltr">mod_perl code is where you are
                              sending the http return status to make
                              sure the client doesn't timeout waiting
                              for the server to respond.</p>
                          </div>
                          <br>
                          <div class=3D"gmail_quote">
                            <div dir=3D"ltr" class=3D"gmail_attr">On Wed,
                              Apr 23, 2025, 2:19=E2=80=AFPM Joseph He &lt;=
<a
                                href=3D"mailto:[email protected]"
                                rel=3D"noreferrer" target=3D"_blank"
                                moz-do-not-send=3D"true"
                                class=3D"moz-txt-link-freetext">joseph.he.=
[email protected]</a>&gt;
                              wrote:<br>
                            </div>
                            <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
                              <div dir=3D"ltr">Thanks, all.
                                <div>Is that Apache timeout controlled
                                  by its configuration=C2=A0"Timeout"?=C2=
=A0</div>
                                <div>I don't think it has anything to do
                                  with modPerl. Am I=C2=A0missing somethin=
g?</div>
                                <div>Thanks.</div>
                              </div>
                              <br>
                              <div class=3D"gmail_quote">
                                <div dir=3D"ltr" class=3D"gmail_attr">On
                                  Wed, Apr 23, 2025 at 1:41=E2=80=AFPM Mit=
hun
                                  Bhattacharya &lt;<a
                                    href=3D"mailto:[email protected]"
                                    rel=3D"noreferrer noreferrer"
                                    target=3D"_blank"
                                    moz-do-not-send=3D"true"
                                    class=3D"moz-txt-link-freetext">mithnb=
@gmail.com</a>&gt;
                                  wrote:<br>
                                </div>
                                <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">
                                  <div dir=3D"auto">Timeout happens
                                    because of how we handle the
                                    request. Timeout is basically no
                                    response came back. Why that happens
                                    is because we think we want to have
                                    a correct response. Unfortunately
                                    for long running requests the
                                    correct response shouldn't be via
                                    http response code or we face
                                    situations like this. Instead reply
                                    with a 200 OK immediately and then
                                    provide correct status in the
                                    message body. Once a response
                                    code/header has been sent timeout
                                    won't trigger and you could
                                    potentially hold the connection for
                                    hours without a problem.</div>
                                  <br>
                                  <div class=3D"gmail_quote">
                                    <div dir=3D"ltr" class=3D"gmail_attr">=
On
                                      Wed, Apr 23, 2025, 9:32=E2=80=AFAM A=
ndreas
                                      Mock &lt;<a
href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer"
                                        target=3D"_blank"
                                        moz-do-not-send=3D"true"
                                        class=3D"moz-txt-link-freetext">an=
[email protected]</a>&gt;
                                      wrote:<br>
                                    </div>
                                    <blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">Hi
                                      Joseph,<br>
                                      <br>
                                      your description is very vague, so
                                      can only answer on some
                                      assumptions:<br>
                                      <br>
                                      It sounds like a timeout is fired
                                      somewhere.<br>
                                      <br>
                                      Best advice in these situations:
                                      Log as many steps as you can. Keep
                                      your <br>
                                      eyes open on TCP/IP and higher
                                      level timeouts.<br>
                                      <br>
                                      Declare only ONE instance
                                      responsible for a retry: Either
                                      the app server <br>
                                      calling the dispatcher with
                                      several tries or the dispatcher
                                      trying for <br>
                                      himself. Not both.<br>
                                      <br>
                                      Best regards<br>
                                      Andreas<br>
                                      <br>
                                      <br>
                                      Am 23.04.2025 um 16:21 schrieb
                                      Joseph He:<br>
                                      &gt; All, good day.<br>
                                      &gt;<br>
                                      &gt; Here is the issue I have.<br>
                                      &gt; My entire application is
                                      running on ModPerl/Apache
                                      environment.<br>
                                      &gt; I send Http::Request with
                                      data load from my App server to a
                                      dispatch <br>
                                      &gt; server thru LWP::UserAgent, I
                                      set the timeout 600 seconds.<br>
                                      &gt;<br>
                                      &gt; The dispatch server is
                                      supposed to manipulate the data
                                      and send the <br>
                                      &gt; data to an external SFTP
                                      server. Because the SFTP can fail,
                                      it will <br>
                                      &gt; keep trying up to 4 times
                                      with 30 seconds sleep in case that
                                      SFTP <br>
                                      &gt; connection fails.<br>
                                      &gt;<br>
                                      &gt; Recently, I found that I
                                      uploaded the file twice sometimes.
                                      I figured <br>
                                      &gt; out the root cause is that my
                                      Dispatch server returns 'failure'
                                      at 6 <br>
                                      &gt; minutes while it keeps trying
                                      to do the SFTP. The App server <br>
                                      &gt; received=C2=A0HTTP::Response wi=
th
                                      error status so it issued another
                                      call to <br>
                                      &gt; send data. It turns out I
                                      uploaded the identified file
                                      twice.<br>
                                      &gt;<br>
                                      &gt; Anybody has this sort of
                                      experience? Why does the
                                      dispatch=C2=A0server <br>
                                      &gt; return 'error' while it still
                                      processes the data?<br>
                                      &gt;<br>
                                      &gt; Thanks a lot,<br>
                                      &gt; Joseph<br>
                                      &gt;<br>
                                    </blockquote>
                                  </div>
                                </blockquote>
                              </div>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                    </blockquote>
                  </div>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>

--------------t57e8G59J1Tzt2FhU00f58jn--