I just noticed something peculiar. When I pull the network cable from my computer on which a RO client application runs, my RO methods throw an “EROSuperChannelException (No connection available)” as expected, but strangely enough, the channel does not trigger the “onDisconnect” event. I would expect the channel to trigger an “OnDisconnect” event before firing the exception. When I re-insert the cable, the channel triggers an “OnConnect” event as expected.
A more reliable pairing of OnDisconnect and OnConnect events would enable us to better monitor and protocol the availability of certain network connections.
Hello,
The channel triggers OnConnected and OnDisconnected events when client properly connect and disconnect.
When you pull the network cable from a computer it’s abnormal situation, so you should process in manually. You
can use OnException event for this purpose.
Well, the channel does trigger “onconnected” after I re-insert the cable so it’s a bit inconsistent… What would be a 100% reliable way for me to evaluate OnException to find out if the exception was raised by a broken channel? Something like the code below?
Thanks for your patience with me,
Arthur
{Event}
procedure TBinaryChannelModule.SynapseChannelException(
Sender: TROTransportChannel; anException: Exception; var aRetry: Boolean);
begin
if (anException IS eROSuperChannelException) and
(anexception.message=‘No connection available’) {DUH…}
then fconnected:=False;
end;
{Event}
procedure TBinaryChannelModule.SynapseChannelDisconnected(Sender: TObject);
begin
fconnected:=False;
end;
{Event}
procedure TBinaryChannelModule.SynapseChannelConnected(Sender: TObject);
begin
fconnected:=True;
end;
Function tBinaryChannelModule.AreWeReallyConnected:Boolean;
Begin
Result:=SynapseChannel.connected and fconnected;
End;
What would be a 100% reliable way for me to evaluate OnException to find out if the exception was raised by a broken channel? Something like the code below?
For different channels anException.Message can be also different. You should check it.
That’s what I do in the code above but I have a very bad feeling about it; if Remobjects ever decides to change the text message (maybe localize it, or change capitalization) it would instantly break my code…
I would be much much happier if the super channel would fire an “ondisconnected” event if it finds out that the connection no longer works. It would be only logical since it also fires an “onconnected” as soon as the connection is back… Under the current state of things, I can have lots of “onconnected” events without ever an “ondisconnected” in between them.
Hello,
As a variant you can ping your server by a dummy remote method in timer. If any error connection occurs you can deactivate all other channels and generate OnDisconnected event.
Sorry, but most of the servers are behind NAT routers having a port forwarding. Most of these routers block ICMP messages so I can’t use that. (And if I could, it would only tell me that the router is working, not the server…). I am currently, as a workaround, using the OnException event and testing the exception message for the “No connection available” string. I just hope and pray that you guys never change that string…