How to catch ESynapseError with RoSynapseSuperTcpChannel?

I’m sorry. Sometimes i feel like a real beginner. I don’t see the solution right now.
Delphi 11.1 , RO

  • place a TROSynapseSuperTCPChannel on the form.
  • place a button on the form.
  • assign channel.OnException.
  • set Channel.Autoreconnect to true
  • set host and port to a not existing server
  • set to true

Now neither a try/except over := true nor channel.onexception will catch the exception ESynapseError “Connection refused”.

In unit uROSynapseSuperTCPChannel.pas the exception has been raised. But i don’t see how to catch it?

procedure TROSynapseClientSuperConnection.Client_Connect(const aHost: string; const aPort: Integer; aSSL: Boolean);
  Connection.Connect(aHost, IntToStr(aPort));
  if Connection.LastError <> 0 then raise ESynapseError.Create(Connection.LastErrorDesc);
  if aSSL then Connection.SSLDoConnect;
  if Connection.LastError <> 0 then raise ESynapseError.Create(Connection.LastErrorDesc);


get testcase from another your topic
change 2 lines and add exception classname

procedure TClientForm.ROChannelServerLocatorAssignment(
  Sender: TROTransportChannel; aLocator: TROServerLocator;
  aException: Exception);
  if Assigned(aException) then
    Log(Format('Exception: %s:%s.', [aException.ClassName, aException.Message])); //changed
procedure TClientForm.ROChannelException(Sender: TROTransportChannel;
  anException: Exception; var aRetry: Boolean);
  Log(anException.ClassName +':'+ anException.Message); //changed

Also this is not working in my environment. Please start the attached very basic sample (just a channel, no server locator). In my environment no exception will be chatched. In Debugger i get the exception in the IDE as you see in the screenshot at my previous post. Outside nothing happens. Why is that? What if you hit the button in the test sample?

debugger exception

Another question: In this state (after hitting the button outside the ide) the application will not close at all (probably because of autoreconnect?). (1.9 KB)


disable autoreconnect, after this, I have

note: you need to change % with %s here, otherwise Format won’t work correctly:

  AddLog(Format('channel exception classname: %, msg: %s',[anException.ClassName, anException.Message]));

Your screenshot is what i would expect also.

But here it does not work like this (Format % instead %s was a typo).

What could be the reason for the behaviour here?

And what do you mean after disabling autoreconnect? If not it should log the exception continously - isnt it?


When AutoReconnect is True, error is handled internally so the OnException event isn’t fired.
Channel is trying to reconnect in loop.

try to set aRetry := True instead of AutoReconnect if you want to handle errors by yourself:

procedure TForm1.ROSynapseSuperTCPChannel1Exception(Sender: TROTransportChannel; anException: Exception; var aRetry: Boolean);
  AddLog(Format('channel exception classname: %s, msg: %s',[anException.ClassName, anException.Message]));
  aRetry := True; //<<<<<<<<

O.K i see. In my opinion this design is not useful. I would expect a channel exception also on enabled autoreconnect property? One has two know at least the first time if something get wrong and why.

Another question related to this: In the given sample - its not possible to close the application after set to True. Even if i set to false in form destroy. Neither if autoreconnect is set to true nor if one set aRetry := True in the channel exception. I thought this was possible in former versions?

How to close the application in this case?


if you set aRetry to False, you can close application.

check testcase: (5.5 KB)

Thanks Evgeny, i’ll go with that approach.