複数のシステムからデータを受信し、それらをデータベースに追加し、最新の受信データで別のアプリケーション (クライアント) を更新するサーバーがあります。このクライアント (どちらも同じコンピューターで実行されます) は、データを整理された形式で表示し、その上で何らかの処理を行います。さらに、サーバーを使用してデータベースでクエリを実行できます。そのため、サーバーから関数を使用して履歴データを取得します。
この通信には WCF を使用しており、サーバーは .config で次のように宣言されています。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ServiceName">
<endpoint binding="netTcpBinding" contract="IServiceName">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/msservice"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
クライアントは次の構成を使用します。
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxConnections="10" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:5050/msservice" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService" contract="Server.IService" name="NetTcpBinding_IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
クライアントがサービスを作成する (サーバーに接続する) と、サブスクライブと呼ばれるサービス関数が使用されます。これにより、サーバーに接続されたクライアント リストにクライアントが含まれます。新しいデータが到着すると、すべてのクライアントでイベントが発生します。
ただし、クライアントが一定の非アクティブ状態になると (反対のことが非常に高い頻度で発生するにもかかわらず、定期的にサーバーにメッセージを送信しないため)、障害状態になります。これが発生すると、サーバー関数のすべてのクライアント呼び出しで例外が発生します。
サーバー側またはクライアント側のいずれかで、クライアントがクライアントからメッセージを受信し、クライアントからの関数呼び出しがサーバーによって実行されることを保証するために、チャネルがダウンするたびに自動的に再接続したいと考えています。
助けてくれてどうもありがとう!