In my code I have 2 ServiceClients
var client = new ServerEventsClient(baseUrl, "home")
{
OnConnect = OnConnect,
OnCommand = HandleIncomingCommand,
OnMessage = HandleIncomingMessage,
OnException = OnException,
OnHeartbeat = OnHeartbeat
};
and
var jsonClient = new JsonServiceClient(baseUrl);
string publicKeyXml = jsonClient.Get(new GetPublicKey());
var cryptoClient = jsonClient.GetEncryptedClient(publicKeyXml);
Notice the OnException handler in the first one. The confusing part is that when cyptoClient throws an error it gets handled with the first clients' OnException handler. Is this how it should work? I didn't set any exception handlers for the 2nd client as there is no option to do so.
This isn't a valid conclusion, the ServerEventsClient.OnExceptionReceived()
only gets called in 4 locations:
You may think they're related because your ServiceClient request may have caused an exception in the Server Event Stream connection, however if there was an exception with the ServiceClient request it would be thrown from the call-site, i.e:
try
{
client.Get(request);
}
catch(WebServiceException ex) { ... }