我有一个自托管并通过另一个服务启动的 WCF 服务。在 Visual Studio 中调试,它们工作得很好,直到我app.config
为服务客户端添加端点配置。此服务的一些客户端将是本地的,而其他客户端将是远程的。我尝试只为命名管道设置客户端端点,如果有一个客户端端点指向该服务,以及一个使用该端点的客户端(即使它甚至不应该在服务尝试启动时被实例化)我得到一个异常告诉我 0.0.0.0:8524 正在使用中。下面是相关配置:
<service name="EventService.EventPublishingService">
<clear />
<endpoint binding="netTcpBinding" address="net.tcp://localhost:8524/EventPublishingService" contract="EventService.Contracts.IEventPublishService">
</endpoint>
<endpoint address="net.tcp://localhost:8524/EventPublishingService/mex" binding="mexTcpBinding" contract="IMetadataExchange">
</endpoint>
<endpoint address="net.pipe://localhost/EventPublishingServicePipe"
binding="netNamedPipeBinding" contract="EventService.Contracts.IEventPublishService"
listenUriMode="Explicit">
</endpoint>
<host>
</host>
</service>
对于客户端端点,我都尝试过
<endpoint address="net.tcp://localhost:8524/EventPublishingService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventPublishService"
contract="AGX.Atlas.EventService.Contracts.IEventPublishService" name="NetTcpBinding_IEventPublishService">
</endpoint>
和
<endpoint address="net.pipe://localhost/EventPublishingServicePipe"
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IEventPublishService"
contract="AGX.Atlas.EventService.Contracts.IEventPublishService" name="NetNamedPipeBinding_IEventPublishService">
</endpoint>
在删除客户端绑定时,我已经从服务中删除了 net.pipe 绑定,以确保它没有做一些奇怪的事情。还是同样的问题。
这是绑定配置:
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IEventPublishService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IEventPublishService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
<binding name="NetTcpBinding_IEventSubscriptionService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>