CGI/FastCGI and WS request with a max time response

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CGI/FastCGI and WS request with a max time response

Marcos Douglas B. Santos
Hi,

I have a FastCGI application which needs to receive an user request but, in some cases, the app should consume a WebService(WS) before make the response to the user.
The problem is that the WS could take so long time that the entire request will broke with a "time out".

My question is: Can I consume this WS with a max time to wait?
Would be better doing this in the code instead of change parameters in the webserver. But, if there is no (simple) way to do that in the code, the webserver more used to this app is Microsoft IIS.

Best regards,
Marcos Douglas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: CGI/FastCGI and WS request with a max time response

Michael Van Canneyt


On Thu, 4 Jan 2018, Marcos Douglas B. Santos wrote:

> Hi,
>
> I have a FastCGI application which needs to receive an user request but, in
> some cases, the app should consume a WebService(WS) before make the
> response to the user.
> The problem is that the WS could take so long time that the entire request
> will broke with a "time out".
>
> My question is: Can I consume this WS with a max time to wait?

If you use a thread to consume it, yes.

Without more info on how you consume this webservice, it's difficult to
answer this.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: CGI/FastCGI and WS request with a max time response

Free Pascal - General mailing list
In reply to this post by Marcos Douglas B. Santos
> The problem is that the WS could take so long time that the entire request
will broke with a "time out".

I suggest making the request handling asynchronous instead. So request will
only register and return some unique id to the requester, then do call to
the WS in background thread. An endpoint shall be provided that when given a
unique id will check whether the corresponding thread has finished executing
or not, returning 200 + response data when done, and 202 if still in
progress. This endpoint shall be called in regular interval by the
requester, until it finishes processing or your server dies (500).




--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: CGI/FastCGI and WS request with a max time response

Marcos Douglas B. Santos
In reply to this post by Michael Van Canneyt
On Thu, Jan 4, 2018 at 6:33 PM, Michael Van Canneyt
<[hidden email]> wrote:
>
> If you use a thread to consume it, yes.
>
> Without more info on how you consume this webservice, it's difficult to
> answer this.

Yes, sorry. I should explained more.
I'm using WST -> http://svn.code.sf.net/p/lazarus-ccr/svn/wst (rev.
5836) to consume WS.
Until now, I didn't find how to set a timeout in WST objects — is this possible?
As you already said, I thought to use a thread, but I may need to
control this manually... ideas how to do this as simple as possible?

My requirement is: If WS do not respond in "X seconds", forget it and
return the "code Y".

Regards,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: CGI/FastCGI and WS request with a max time response

Marcos Douglas B. Santos
In reply to this post by Free Pascal - General mailing list
On Thu, Jan 4, 2018 at 10:33 PM, leledumbo via fpc-pascal
<[hidden email]> wrote:

>> The problem is that the WS could take so long time that the entire request
> will broke with a "time out".
>
> I suggest making the request handling asynchronous instead. So request will
> only register and return some unique id to the requester, then do call to
> the WS in background thread. An endpoint shall be provided that when given a
> unique id will check whether the corresponding thread has finished executing
> or not, returning 200 + response data when done, and 202 if still in
> progress. This endpoint shall be called in regular interval by the
> requester, until it finishes processing or your server dies (500).

Interesting, but I can't do this way.
It should be just one call from client (desktop app and website) to my
REST service.
My service encapsulates the WS.
As I wrote previously to Michael, if the WS do not respond in "X
seconds", my service should forget it and return a "code Y".

Best,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal