in src/Microsoft.Azure.Relay/HybridConnectionListener.cs [483:520]
async Task OnAcceptCommandAsync(ListenerCommand.AcceptCommand acceptCommand)
{
Uri rendezvousUri = new Uri(acceptCommand.Address);
Uri requestUri = this.GenerateAcceptRequestUri(rendezvousUri);
var listenerContext = new RelayedHttpListenerContext(
this, requestUri, acceptCommand.Id, "GET", acceptCommand.ConnectHeaders);
listenerContext.Request.SetRemoteAddress(acceptCommand.RemoteEndpoint);
RelayEventSource.Log.RelayListenerRendezvousStart(listenerContext.Listener, listenerContext.TrackingContext.TrackingId, acceptCommand.Address);
try
{
var acceptHandler = this.AcceptHandler;
bool shouldAccept = acceptHandler == null;
if (acceptHandler != null)
{
// Invoke and await the user's AcceptHandler method
try
{
shouldAccept = await acceptHandler(listenerContext).ConfigureAwait(false);
}
catch (Exception userException) when (!Fx.IsFatal(userException))
{
string description = SR.GetString(SR.AcceptHandlerException, listenerContext.TrackingContext.TrackingId);
RelayEventSource.Log.RelayListenerRendezvousFailed(this, listenerContext.TrackingContext.TrackingId, description + " " + userException);
listenerContext.Response.StatusCode = HttpStatusCode.BadGateway;
listenerContext.Response.StatusDescription = description;
}
}
await this.CompleteAcceptAsync(listenerContext, rendezvousUri, shouldAccept).ConfigureAwait(false);
}
catch (Exception exception) when (!Fx.IsFatal(exception))
{
RelayEventSource.Log.RelayListenerRendezvousFailed(this, listenerContext.TrackingContext.TrackingId, exception);
RelayEventSource.Log.RelayListenerRendezvousStop();
}
}