|
Hi - thanks for all the good work so far!
We had a situation in Azure where the software load balancer is establishing a connection every minute. This causes an exception because we are running a wss server, and the handshake fails.
We discovered the IP address of the loadbalancer by modifying the code to throw a custom exception (SocketSessionException) into the logger which had a ISocketSession property that carried the session details - this way we were able to log the details of
the client and discover the IP Address:
Updated the SocketSession.cs and added a method HandleException:
public void HandleException(Exception e)
{
SocketSessionException exception = new SocketSessionException(e.Message, e) { SocketSession = this };
AppSession.Logger.LogError(exception);
Close(CloseReason.SocketError);
}
And in the AsyncStreamSocketSession modified this:
private void OnBeginInitStream(IAsyncResult result)
{
var sslStream = result.AsyncState as SslStream;
try
{
sslStream.EndAuthenticateAsServer(result);
}
catch (Exception e)
{
HandleException(e);
return;
}
m_Stream = sslStream;
}
This provides the logger with much more information about the context of an exception. Of course, if there is no session, the Exception's Session property would be null.
Does it sound like a sensible idea?
Thanks
|