#1 2021-08-03 18:59:25

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

OnFailed and reconnection

Hi,

I implemented the OnFailed method of the TSQLRestClientURI class so that it is possible to perform reconnections between client and server when there is a failed request. It worked correctly but as the method is only called when the request fails, the request that originated the method is not executed. I decided with a repeat loop for him to resend the request until it returns the status OK. It worked, but I don't think it's the best option. Someone has used or knows some practice to perform these reconnections instantly.

Note: when I say request I am referring to a simple TSQLRestClientURI.Add

Reference: https://synopse.info/forum/viewtopic.php?id=5694

Offline

#2 2021-08-13 06:25:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,346
Website

Re: OnFailed and reconnection

If there is a connection problem, e.g. a closed connection, the client should recreate the socket directly before executing the request.
But you are right: if the request started on an existing connection, but during the process it was broken, it won't recreate the socket, nor resend the request.

It is up to the client logic to manage errors and react to this.
The OnFailed method is not only called when the connection is broken. It is called e.g. with REST remote access when you request an ID or run a service which does not exist, or to which you don't have the access right.
So automatic resend may not be a good solution.

Offline

Board footer

Powered by FluxBB