Web クライアント (Java で記述) によって照会されているWCF
サービス (IIS 7、.NET 4、Windows Server 2008 R2 Enterprise) があります。ただし、複数の要求が WCF サービスに同時に送信されると、クライアントは"java.net.SocketException: Connection reset"
. 多くのスレッドを参照し、WCF サービスの構成を調整しようとしましたが、問題はまだ修正されていません。以下に詳細を示します。
web.config (WCF サービスの):
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="Off"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" />
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Alpha.BetaBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<!-- below is for huge files-->
<!-- dataContractSerializer maxItemsInObjectGraph="2147483647" / -->
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="BetaEndpointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Alpha.Beta" behaviorConfiguration="Alpha.BetaBehavior">
<endpoint address="" kind="webHttpEndpoint" behaviorConfiguration="BetaEndpointBehavior" binding="webHttpBinding" contract="Alpha.IBeta">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<diagnostics wmiProviderEnabled="true">
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
/>
</diagnostics>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource" switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\inetpub\wwwroot\bin\RequestLogs\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>
WCF サービスの動作: *編集: 以下のコメントの提案に従って、ConcurrencyMode = ConcurrencyMode.Multiple
ServiceBehavior に追加されました (ただし、それでも同じエラーが発生します)
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
また、たとえば、Web クライアントから 2 つの同時要求を送信すると (たとえば、Firefox の 2 つの異なるタブから WCF サービスを同時に照会するなど)、そのうちの 1 つは正しい結果を返しますが、もう 1 つはSocketException
エラーになります。その後、エラーを返したクエリを再実行すると、SocketException
正しく機能します。
私も有効にWCF Tracing
しました(これは初めてです)。次の例外メッセージが表示されます。
The communication object, System.ServiceModel.Channels.TransportReplyChannelAcceptor+TransportReplyChannel, cannot be used for communication because it has been Aborted.
..次のスタック トレースを使用:
System.ServiceModel.Channels.CommunicationObject.ThrowIfAborted()
System.ServiceModel.Channels.InputQueueChannel`1.EndDequeue(IAsyncResult result, TDisposable& item)
System.ServiceModel.Channels.ReplyChannel.EndTryReceiveRequest(IAsyncResult result, RequestContext& context)
System.ServiceModel.Dispatcher.ReplyChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue`1.Shutdown(Func`1 pendingExceptionGenerator)
System.ServiceModel.Channels.InputQueueChannel`1.OnClosing()
System.ServiceModel.Channels.CommunicationObject.Abort()
System.ServiceModel.Dispatcher.ListenerHandler.AbortChannels()
System.ServiceModel.Dispatcher.ListenerHandler.OnAbort()
System.ServiceModel.Channels.CommunicationObject.Abort()
System.ServiceModel.Dispatcher.ChannelDispatcher.OnAbort()
System.ServiceModel.Channels.CommunicationObject.Abort()
System.ServiceModel.ServiceHostBase.OnAbort()
System.ServiceModel.Channels.CommunicationObject.Abort()
System.ServiceModel.ServiceHostingEnvironment.HostingManager.Abort()
System.ServiceModel.ServiceHostingEnvironment.HostingManager.Stop(Boolean immediate)
System.Web.Hosting.HostingEnvironment.StopRegisteredObjects(Boolean immediate)
System.Web.Hosting.HostingEnvironment.InitiateShutdownWorkItemCallback(Object state)
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
System.Threading.ThreadPoolWorkQueue.Dispatch()
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
最後に、サーバー側では、これが発生するたびに Visual Studio ポップアップが表示され、次のように表示されます"An unhandled .NET Microsoft framework exception occurred in w3wp.exe [1248]"
(Visual Studio を開いてコードをテストしています)。
これに光を当てるのを手伝ってくれる人はいますか?WCF サービスは適切に構成されていますが、Java Web クライアントから微調整を行う必要があるのでしょうか?
前もって感謝します。