You are not logged in.
Pages: 1
Hello Again
So, i'm having a little problem when I try to use a service and it takes longer than usual, I get an Exception from Time out, I know that with WebSocket i can do this, but I was wondering if there is a way to do this with httpSQLClient and httpSQLServer because I know it is not perfomatic or ideal that a query takes so long, but there will be cases that the internet may be slow in some report or something of the genre, it would not stop the Service, even if it takes a while, and i do not found anything that helps to do this in the forum and documentation ( i know Callbacks can work, but i'm trying to do without then). already try to use setTimeout with the Service but not work
FactoryService := FRest.ServiceDefine(TVendaService, [IVendaService], sicClientDriven);
FactoryService.SetTimeoutSec(99999999);
Sorry about the Bad English
Best Regards,
Shadownildo
Offline
Just use a queue and a background thread, then two methods, like MyProcessStart and IsMyProcessFinished to pool the service.
Thanks for The Answer Ab!
I'm sorry to ask this, but you have a Sample? because i can't visualize this suggestion and for me study this better ?
Offline
Check your http client constructor, there are some timeout parameters there you might find useful.
As for understanding what ab said, the service method that executes on the server side should not take long, in fact, it should exit as soon as possible. If you know that it will take a long time then move (or rather schedule) the work to a worker thread instead, this avoids blocking the connection thread that received your client request and as a result, solves the timeout issue.
This introduces a different problem, how will the client know when the work has finished processing? Pooling, which is basically about asking the server for the current work status, at some interval. For example, in your service definition "TVendaService" you would define a function like "function IsWorkFinished(WorkID : Integer) : Boolean", and on the client side, call this function every X ms/sec in a timer. This is just basic example,
typically you would include status codes instead "procedure IsWorkFinished(WorkID : Integer; out Status: Integer)", like "WORK_IS_QUEUED","WORK_IS_PROCESSING","WORK_FINISHED" etc..., you get the gist.
Offline
Check your http client constructor, there are some timeout parameters there you might find useful.
As for understanding what ab said, the service method that executes on the server side should not take long, in fact, it should exit as soon as possible. If you know that it will take a long time then move (or rather schedule) the work to a worker thread instead, this avoids blocking the connection thread that received your client request and as a result, solves the timeout issue.
This introduces a different problem, how will the client know when the work has finished processing? Pooling, which is basically about asking the server for the current work status, at some interval. For example, in your service definition "TVendaService" you would define a function like "function IsWorkFinished(WorkID : Integer) : Boolean", and on the client side, call this function every X ms/sec in a timer. This is just basic example,
typically you would include status codes instead "procedure IsWorkFinished(WorkID : Integer; out Status: Integer)", like "WORK_IS_QUEUED","WORK_IS_PROCESSING","WORK_FINISHED" etc..., you get the gist.
Thanks For the Answer pvn0!
if i understand it right, it will work Like a CallBack ? that i have to a code like
Procedure IsWorking(const WorkID: Integer; Out Status :integer);
that implements something like this
procedure IsWorking(WorkID : Integer; out Status: integer)
begin
if WorkId = 0 then
break;
Status := Service.Work(workId); // Example
end;
We are using ID to exemplify this , but How i get that ID or Name,and how i know is still Working? This part is a bit confusing for me, i understand i will have to create A Thread Pool, but how Find the Same Work instance is what i don't know how
Sorry about fo the newbie questions and the Bad English
Best Regards
Shadownildo
Offline
Pages: 1