首页 新闻 会员 周边 捐助

并发调用WCF服务,服务进程异常终止

0
悬赏园豆:50 [待解决问题]

各位好!

       Caterpillar-lj在调用WCF服务时,遇到服务进程异常终止,不知是什么原因。各位.NET前辈请帮忙看看,有遇到同样情况的或对此问题有什么想法的,给点建议,本人不胜感激!

场景:

两台计算机A和B

A为服务器,同时运行寄主于 Windows Service的WCF服务和调用服务的客户端程序

B为客户机,运行调用服务的客户端程序

WCF服务程序:通过一主键去数据库(oracle)查询信息。

WCF服务配置信息:

<services>   

    <!--用户信息服务-->
      <service name="Test.DataService.UserService" behaviorConfiguration="BasicServiceBehavior2">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://10.9.146.112:1220/UserService" />
            <add baseAddress="http://10.9.146.112:1110/UserService" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="DuplexBindingWithUserName" contract="Test.ServiceContract.IUserServices">
          <identity>
            <dns value="TestCert" />
          </identity>
        </endpoint>
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" contract="Test.ServiceContract.IUserServices" />
        <endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
        <endpoint address="MEX" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>

  </services>

<behaviors> 

   <serviceBehaviors>

       <behavior name="BasicServiceBehavior2">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <clientCertificate>
              <authentication certificateValidationMode="None" />
            </clientCertificate>
            <serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="TestCert" />
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Test.ValidateUtility.CertValidateUtility,Test.ValidateUtility" />
          </serviceCredentials>
          <serviceThrottling maxConcurrentSessions="1000" />
        </behavior>
      </serviceBehaviors>

</behaviors>

  <bindings>
      <netTcpBinding>
        <binding name="DuplexBindingWithUserName" sendTimeout="00:00:10" transactionFlow="true" transactionProtocol="OleTransactions" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="Message">
            <message clientCredentialType="UserName" />
          </security>
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="409600" maxNameTableCharCount="16384" />
          <reliableSession enabled="true" />
        </binding>
    </netTcpBinding>

   </bindings>

客户端程序:A、B运行的客户端程序代码一样,设定同一时间,开1000个线程通过代理类去调用A的WCF服务。

测试结果:WCF服务进程异常终止。

操作系统:Windows 2003

.net framework 版本:4.0

 

A服务器 系统事件查看器 应用程序记录信息如下:

Application: Test.ServiceHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ServiceModel.CommunicationException
Stack:
   at System.Runtime.Fx+IOCompletionThunk.UnhandledExceptionFrame(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

注:WCF使用控制台寄主,在客户端并发调用过程中,控制台进程会终止

Caterpillar-lj的主页 Caterpillar-lj | 初学一级 | 园豆:152
提问于:2014-01-05 15:11
< >
分享
所有回答(2)
0

打开WCF的诊断服务,直接上去看WCF Log,包治。

Ninja_Lu | 园豆:289 (菜鸟二级) | 2014-01-05 15:45

本人对服务诊断没什么了解,不知如何使用WCF的诊断服务,如果有个例子的话就好了。

支持(0) 反对(0) Caterpillar-lj | 园豆:152 (初学一级) | 2014-01-05 18:15

@Caterpillar-lj: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

支持(0) 反对(0) Ninja_Lu | 园豆:289 (菜鸟二级) | 2014-01-05 19:38

@Ninja_Lu: 好的,我先了解一下,谢谢!

支持(0) 反对(0) Caterpillar-lj | 园豆:152 (初学一级) | 2014-01-06 10:43
0

如果业务逻辑代码确认没问题的话 试试:

可以试试 maxConnections="10000"  <netTcpBinding>
        <binding name="DuplexBindingWithUserName" sendTimeout="00:00:10" transactionFlow="true" transactionProtocol="OleTransactions" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"  maxConnections="10000" >

英文错误好费解;

条子# | 园豆:106 (初学一级) | 2014-01-10 16:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册