IIS Host 的WCF大数据量大并发调用的时候IIS返回403错误

版权声明

请尊重原创作品。转载请保持文章完整性,并以超链接形式注明原始作者“tingsking18”和主站点地址,方便其他朋友提问和指正。

昨天下午在作WCF服务的大数据量和大量并发的测试,同时启动40个客户端进程,在碰到比较耗时的服务处理时,IIS服务器返回403错误。异常信息如下:

System.ServiceModel.Security.MessageSecurityException: 使用客户端身份验证方案“Anonymous”禁止 HTTP 请求。 -- -> System.Net.WebException: 远程服务器返回错误: (403) 已禁止。 在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- 内部异常堆栈跟踪的结尾 --- Server stack trace: 在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory) 在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 在 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 terminal.ViolationService.IViolationService.QueryVioImg(String vioSeq) 在 terminal.ViolationService.ViolationServiceClient.QueryVioImg(String vioSeq) 位置 D:\Backup\我的文档\Visual Studio 2008\Projects\terminal\terminal\Service References\ViolationService\Reference.cs:行号 299 在 terminal.Program.Main(String[] args) 位置 D:\Backup\我的文档\Visual Studio 2008\Projects\terminal\terminal\Pro gram.cs:行号 34

通过各种方法监控WCF的错误消息,可是这些出错的调用都没有到达WCF,所有监测WCF的地方和WCF的TraceLog都没有任何的错误。随后又拿出终极法宝wireshark,抓包也看不到任何错误,就是客户端请求了服务器一下,然后IIS就返回了403错误,并报告上面的异常。于是把WCF的服务部署到了Win2003server的iis6下面。这样程序正常运行不会有任何错误。于是查了一下IIS5.1 造成403错误的原因。原来是IIS5.1的最大连接数的问题。于是总结了一下:

同时修改了几个方面:

1.windowsXP SP3的TCP连接数,改为512。(有专门的工具破解)

2.WCF会话数,调用数和实例数

<behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" /> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors>

其实这个可以不改,如果是默认的化,所有的线程就会像进入临界区一样。没有执行的线程将会等待。

3.修改IIS的最大连接数。

cd C:\Inetpub\AdminScripts

cscript adsutil.vbs set w3svc/MaxConnections 40
iisreset

由于在windows的profressional版本的系统中对IIS的客户端同时连接的数目作了限制,默认为10个。而在server版本的操作系统中不存在这种限制。还是建议大家用Server版本的windows系统

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值