http://www.cnblogs.com/kklldog/p/5037006.html

wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误。一开始以为服务停止了,上服务器检查目标服务好好的活着。于是开始查原因。

一般来说目标积极拒绝(TCP 10061)的异常主要是2种可能:

1:服务器关机或者服务关闭

2:Client调用的端口错误或者服务器防火墙没开相应的端口

但是我们的服务本身是可以调用的,只是偶尔报这个错误,说明并不是这2个问题造成的。继续google,在stackoverflow上看到这样一篇:传送门

1
2
3
4
5
6
7
8
9
10
11
12
13
If this happens always, it literally means that the machine exists but that it has no services listening on the specified port, or there is a firewall stopping you.
 
If it happens occasionally - you used the word "sometimes" - and retrying succeeds, it is likely because the server has a full '<strong>backlog</strong>'.
 
When you are waiting to be accepted on a listening socket, you are placed in a backlog. This backlog is finite and quite short - values of 1, 2 or 3 are not unusual - and so the OS might be unable to queue your request for the 'accept' to consume.
 
The backlog is a parameter on the listen function - all languages and platforms have basically the same API in this regard, even the C# one. This parameter is often configurable if you control the server, and is likely read from some settings file or the registry. Investigate how to configure your server.
 
If you wrote the server, you might have heavy processing in the accept of your socket, and this can be better moved to a separate worker-thread so your accept is always ready to receive connections. There are various architecture choices you can explore that mitigate queuing up clients and processing them sequentially.
 
Regardless of whether you can increase the server backlog, you do need retry logic in your client code to cope with this issue - as even with a long backlog the server might be receiving lots of other requests on that port at that time.
 
There is a rare possibility where a NAT router would give this error should it's ports for mappings be exhausted. I think we can discard this possibility as too much of a long shot though, since the router has 64K simultaneous connections to the same destination address/port before exhaustion.

大概意思就是如果这个错误是一直发生的那么可能是服务器或者防火墙的问题,如果这个问题是“Sometime”发生的,那么可能是backlog的 问题。backlog是tcp层面的请求队列,当你调用socket发起请求的时候服务端会排成一个队列,在高并发情况下服务端来不及处理请求,那么有些 请求就被直接被丢弃,于是就报了目标积极拒绝TCP10061的异常。

有了backlog于是继续google关键字“WCF backlog”发现wcf binding配置确实有一个listenBacklog的项目,默认值是10,于是把服务的listenBacklog改成100,问题搞定。

对了添加listenBacklog属性的时候有个注意的是一定要移除一个默认的endpoint      <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />这个endpoint是用来给vs等发现元数据用的,如果这个不移走启动服务的时候会报端口已经被监听的错误。

参考:

http://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it

https://msdn.microsoft.com/en-us/library/ee377061(v=bts.10).aspx

WCF服务在高并发情况下报目标积极拒绝的异常处理 z的更多相关文章

  1. 关于WCF服务在高并发情况下报目标积极拒绝的异常处理

    最近弄了个wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好好的活着.于是开始查原因. 一般来说目标积极拒绝(TCP 10061)的异常主要是 ...

  2. 小D课堂 - 新版本微服务springcloud+Docker教程_6-05 高级篇幅之高并发情况下

    笔记 5.高级篇幅之高并发情况下接口限流特技         简介:谷歌guava框架介绍,网关限流使用 1.nginx层限流 2.网关层限流 开始 mysql最大的连接数就是3千多.如果想把应用搞好 ...

  3. Jackson高并发情况下,产生阻塞

    情况:在高并发情况下,查看线程栈信息,有大量的线程BLOCKED. 从线程栈得知,线程栈中出现了阻塞,锁在了com.fasterxml.jackson.databind.ser.SerializerC ...

  4. Linux的虚拟内存管理-如何分配和释放内存,以提高服务器在高并发情况下的性能,从而降低了系统的负载

    Linux的虚拟内存管理有几个关键概念: Linux 虚拟地址空间如何分布?malloc和free是如何分配和释放内存?如何查看堆内内存的碎片情况?既然堆内内存brk和sbrk不能直接释放,为什么不全 ...

  5. 高并发情况下分布式全局ID

    1.高并发情况下,生成分布式全局id策略2.利用全球唯一UUID生成订单号优缺点3.基于数据库自增或者序列生成订单号4.数据库集群如何考虑数据库自增唯一性5.基于Redis生成生成全局id策略6.Tw ...

  6. c# redis 利用锁(StackExchange.Redis LockTake)来保证数据在高并发情况下的正确性

    之前有写过一篇介绍c#操作redis的文章 http://www.cnblogs.com/axel10/p/8459434.html ,这篇文章中的案例使用了StringIncrement来实现了高并 ...

  7. Java高并发情况下的锁机制优化

    本文主要讲并行优化的几种方式, 其结构如下: 锁优化 减少锁的持有时间 例如避免给整个方法加锁 1 public synchronized void syncMethod(){ 2 othercode ...

  8. Mysql在高并发情况下,防止库存超卖而小于0的解决方案

    背景: 本人上次做申领campaign的PHP后台时,因为项目上线后某些时段同时申领的人过多,导致一些专柜的存货为负数(<0),还好并发量不是特别大,只存在于小部分专柜而且一般都是-1的状况,没 ...

  9. 高并发情况下Linux系统及kernel参数优化

    众所周知在默认参数情况下Linux对高并发支持并不好,主要受限于单进程最大打开文件数限制.内核TCP参数方面和IO事件分配机制等.下面就从几方面来调整使Linux系统能够支持高并发环境. Iptabl ...

随机推荐

  1. Checking the content of the pointer

    https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/d481b7ec-cd67-476c-b2d7-ca3334effa16/h ...

  2. gcviewer待整理

    官网:https://github.com/chewiebug/GCViewer G1 Gabage Collector -XX:+UnlockExperimentalVMOptions -XX:+U ...

  3. OpenJudge计算概论-循环移动

    /*=============================================================================== 循环移动 总时间限制: 1000ms ...

  4. XMLHttpRequest 对象

    XMLHttpRequest 对象 XML XSLTXML 解析器XMLHttpRequest 对象用于在后台与服务器交换数据. 什么是 XMLHttpRequest 对象? XMLHttpReque ...

  5. SET Transaction Isolation Level Read语法的四种情况

    转自:http://www.cnblogs.com/qanholas/archive/2012/01/04/2312152.html 存储过程:SET Transaction Isolation Le ...

  6. oracle11g服务项及其启动顺序

    oracle安装完成后共七个服务,含义分别为: 1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝写入服务,VSS(Volume Shadow Copy Ser ...

  7. openoffice下中文乱码问题解决

    在系统安装完OpenOffice进行pdf文档转换的时候 文档会出现乱码如下: 这里主要有两个原因: 1.上传的文件的编码是Windows上的默认编码GBK,而linux服务器默认编码是UTF-8,这 ...

  8. Partition does not end on cylinder boundary

    fdisk可能会报该消息. DOS/Win95要求分区对齐到cyclinder boundary以适应CHS寻址. 然而现代OS都使用LBA寻址. 使用c命令关闭DOS兼容性检查. 使用u命令切换分区 ...

  9. Dell R410 broadcom网卡驱动更新失败

    问题描述: 最近遇到一个Dell R410 broadcom网卡驱动更新失败的问题.从官网上下载的驱动在安装的过程中都会自己回滚回来,很是困惑. 尝试解决: Dell官网现在提供的驱动一般最少有两种格 ...

  10. Python类,域,方法,对象,继承

    类和对象: 是面向对象编程的两个主要方面,类创建一个新类型,而对象这个类的实例.. 域: 属于一个对象或类的变量被称为域.域有两种类型: 属于每个实例(类的对象)或属于类本身.它们分别被称为实例变量和 ...