How to disable keep-alive for basicHttpRelayBinding for Azure service bus?

I am trying to disable HTTP keep-aliveand I cannot find documentation on how to do this. Ultimately, I sometimes get:

System.ServiceModel.CommunicationException : The underlying connection was closed: The connection that was to be saved was closed by the server

I heard that the best approach is to simply disable HTTP keep-alive.

+1
source share
1 answer

I ended up solving my problem here with a little helper function that takes my basicHttpRelayBinding and modifies it accordingly:

private static System.ServiceModel.Channels.Binding GetBinding(System.ServiceModel.Channels.Binding bIn)
    {
        var bOut = new CustomBinding(bIn);
        var transportElement = bOut.Elements
              .Find<HttpsRelayTransportBindingElement>();
        transportElement.KeepAliveEnabled = false;
        return bOut;
    }
+1

All Articles