WCF服务仅侦听localhost(127.0.0.1)

时间:2017-08-04 07:31:15

标签: c# windows wcf server ip

我有WCF服务,它可以作为Windows服务使用。服务很好,经过100多个客户的测试。但是一台机器只能在localhost上运行。服务托管在Windows Server 2012 r2上。添加' netstat'的图像。在类似的工作服务器上,服务正在监听' 0.0.0.0:88'。

尝试了各种端点' 0.0.0.0:88 / MyService.svc',' 198.xxx:88 / MyService.svc',' HostName:88 / MyService。 SVC'所有工作仅限于当地。

服务配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="connectionString" value="xxxxx"/>
  </appSettings>
  <connectionStrings>    
  </connectionStrings>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BehaviourService">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="FvsBasicHttp" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00"
                 maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="32" maxBytesPerRead="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="FvsWebServiceWcf.FvsService" behaviorConfiguration="BehaviourService" >
        <endpoint name="FvsService" address ="" binding="basicHttpBinding" bindingConfiguration="FvsBasicHttp" contract="FvsWebServiceWcf.IFvsService"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://195.x.x.x:88/MyService.asmx"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:2)

可能的猜测:有人通过将HTTP.SYS设置为仅在localhost接口上侦听来搞砸了计算机。您可以通过运行命令来检查:

netsh.exe http show iplisten

如果它确实按预期返回127.0.0.1,您可能需要删除带有(netsh.exe http delete iplisten ipaddress=127.0.0.1)的条目。不确定是否需要再次添加0.0.0.0才能让它再次运行。