Hi there,
According to my own Question some time ago we’ve changed the reconnect approach from AutoReconnect to ChannelException. This is working about 99%. Unfortunately sometimes some clients on customer site do not reconnect after server service restart. We’ve tried to get deeper adding massive logging.
The EventHandling:
FROChannel.OnConnected := OnChannelStateChanged;
FROChannel.OnDisconnected := OnChannelStateChanged;
FROChannel.OnException := OnChannelException;
FROChannel.OnFailure := OnChannelException;
The OnChannelException looks like this right now:
procedure TServiceCommunication.OnChannelException(Sender: TROTransportChannel; anException: Exception; var aRetry: Boolean);
begin
aRetry:= RetryConnect;
// if FLastConnectedState <> s_disconnected then
TLogger.Log.Debug('channel exception. LastConnectedState: %s, Retry: %s, Host: %s, ExceptionType: %s, Exception: %s, ',
[TRttiEnumerationType.getName(FLastConnectedState), BoolToStr(aRetry, True), FRoChannel.Host, anException.ClassType.ClassName, anException.Message], 'connection');
if aRetry then
begin
if FLastConnectedState <> s_disconnected then
begin
FLastConnectedState := s_disconnected;
FLastErrMsg:= anException.Message;
if anException is EROUnregisteredServerException then
TLogger.Log.Error('EROUnregisteredServerException received!',[],'connection');
if Assigned(FOnConnectionStateChanged) then
FOnConnectionStateChanged(self, FROChannel.Tag, FROChannel, FLastErrMsg);
end;
end;
end;
The OnChannelStateChanged:
procedure TServiceCommunication.OnChannelStateChanged(Sender: TObject);
begin
TLogger.Log.Debug('OnChannelStateChanged. ConnectedState: %s, Host: %s',[BoolToStr(FROChannel.Connected,True), FRoChannel.Host],'connection');
if FROChannel.Connected then
begin
FLastErrMsg:= '';
FLastConnectedState:= s_connected;
end
else
begin
FLastConnectedState:= s_disconnected;
TTask.Run(
procedure
begin
sleep (1000);
TThread.Synchronize(TThread.Current,
procedure
begin
FROChannel.Active:= True;
end);
end);
end;
if Assigned(FOnConnectionStateChanged) then
FOnConnectionStateChanged(self, FROChannel.Tag, FROChannel, FLastErrMsg);
end;
When the server disconnects the client will periodically log the channel exception message as expected.
In 99% when the server comes back the OnChannelStateChanged event is fired.
But sometimes when the server is back online the channel exception logging stops
but the onChanelstateChanged is never fired until client restart.
What could happen here? Obviously “somewhere” the channel did reconnect (because channel exception is not fired anymore) . But the channelstatechanged event is missing.
- Delphi 11.3
- RO 10.0.0.1561
- TROSuperTcpChannel with TLS (supertcps)
Server is .NET.
I was never able to reproduce this behaviour here. Just at customer site.
Thanks for your help