1

I've written created a WCF service inside a Windows service, and for some reason I can't figure out, I deployed the service on a bunch of systems (all nearly identical in OS and configuration), and it works on all but one server. The configuration for all deployments is identical except for the service's base address.

When the service is started, I get no exception when I open the ServiceHost, and when using netstat -anp I can see the socket has been opened by the service's process. I've set up Windows firewall logging for dropped packets, but the log file remains empty.

If I try accessing the WCF service from WCF Test Client, I get the following message:

Error: Cannot obtain Metadata from net.tcp://myhostname:9001/SysMonitorAgent 
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error    
    URI: net.tcp://myhostname:9001/SysMonitorAgent    
    Metadata contains a reference that cannot be resolved: 'net.tcp://myhostname:9001/SysMonitorAgent'.
    There was no endpoint listening at net.tcp://myhostname:9001/SysMonitorAgent that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

I've tried WCF logging, but the log file does not even get created.

The config for the service is as follows:

<system.serviceModel>
  <diagnostics>
    <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
  </diagnostics>
  <bindings>
    <netTcpBinding>
      <binding name="InterfaceServiceNetTcpBinding">
        <security mode="None">
          <transport clientCredentialType="None" protectionLevel="None" />
          <message clientCredentialType="None" />
        </security>
      </binding>
    </netTcpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="InterfaceServiceBehavior">
        <serviceMetadata httpGetEnabled="false" />
        <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service name="SysMonitor.Agent.Interface.InterfaceService" behaviorConfiguration="InterfaceServiceBehavior">
      <endpoint address="" binding="netTcpBinding" bindingConfiguration="InterfaceServiceNetTcpBinding" contract="SysMonitor.Agent.Interface.IInterfaceService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://myhostname:9001/SysMonitorAgent" />
        </baseAddresses>
      </host>
    </service>
  </services>
</system.serviceModel>

I'm kinda lost, because there is NO indication whatsoever as to why it's not working. Any help would be appreciated.

4

2 回答 2

0

在您正在部署的服务器上,是否也在端口 9100 上运行?

好像找不到服务。您是否尝试过更改基地址?

如果您将它部署在伺服系统上并且它不能在其中一个系统上运行,则通常是机器的配置。我会检查

  • .NET 版本
  • 确保此机器上没有设置防火墙以防止绑定
  • 检查您要绑定的端口在这种情况下是否打开 9100
  • 如果需要,请确保任何第 3 方 .dll 都包含在 GAC 或文件夹中。
  • 验证所有 .dll 并且您的代码是最新的。

我看到错误消息说“net.tcp://myhostname:9001/SysMonitorAgent”

您是否尝试将其替换为机器 IP 地址而不是使用主机名?

于 2010-07-30T15:25:51.147 回答
0

除了大卫的观点,检查 windows 服务是否正在运行。

事件日志中有任何错误吗?

于 2010-07-30T16:34:47.530 回答