如何为basicHttpRelayBinding禁用对Azure服务总线的保持活动状态? [英] How do I disable keep-alive for a basicHttpRelayBinding to the Azure service bus?

查看:89
本文介绍了如何为basicHttpRelayBinding禁用对Azure服务总线的保持活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试禁用HTTP keep-alive,但似乎找不到有关如何实现此功能的任何文档.最终,我偶尔会得到:

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 :基础连接已关闭:服务器关闭了预期保持活动状态的连接

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

我听说最好的方法就是禁用HTTP keep-alive.

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

推荐答案

最终,我在这里用一个小辅助函数解决了我自己的问题,该函数接受我的basicHttpRelayBinding并进行了适当修改:

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

这篇关于如何为basicHttpRelayBinding禁用对Azure服务总线的保持活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆