How do I disable keep-alive for a basicHttpRelayBinding to the Azure service bus?

我是研究僧i 提交于 2020-01-06 03:54:28

问题


I'm trying to disable HTTP keep-alive, and I can't seem to find any documentation on how to achieve that. Ultimately, I am occasionally getting:

System.ServiceModel.CommunicationException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server

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


回答1:


Ultimately I solved my own issue here with a little helper function that takes my basicHttpRelayBinding and modifies it appropriately:

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;
    }


来源:https://stackoverflow.com/questions/9047598/how-do-i-disable-keep-alive-for-a-basichttprelaybinding-to-the-azure-service-bus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!