【问题标题】:WCF app Deployed on Win7 Machine and get connection refused errorWCF 应用程序部署在 Win7 机器上并获得连接被拒绝错误
【发布时间】:2010-04-15 09:56:16
【问题描述】:

我创建了一个基于following sample from microsoft 的同步框架应用程序并将其部署到一台新的Windows 7 机器上进行测试。该应用程序运行正常,但当我尝试通信时出现以下错误:

无法连接到 http://localhost:8000/RelationalSyncContract/SqlSyncService/。 TCP 错误代码 10061:无连接 可以因为目标 机器主动拒绝 127.0.0.1:8000。

我想知道我是否缺少某些东西。这是我第一次使用 WCF 并遵循 microsoft 示例代码。

我已禁用防火墙并为 TCP 和 UDP 打开端口 8000。不知道接下来要看什么。如果有帮助,下面是我的 App.config 文件:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true"/>
    <httpRuntime maxRequestLength="32768" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="WebSyncContract.SyncServiceBehavior" name="WebSyncContract.SqlWebSyncService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="largeMessageHttpBinding" contract="WebSyncContract.ISqlSyncContract">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/RelationalSyncContract/SqlSyncService/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <!-- We are using Server cert only.-->
        <binding name="largeMessageHttpBinding" maxReceivedMessageSize="204857600">
          <readerQuotas maxArrayLength="1000000"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WebSyncContract.SyncServiceBehavior">
          <!-- 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"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

谢谢,非常感谢您的帮助。

【问题讨论】:

  • 我认为这可能与WCF服务主机没有启动有关..所以需要找到如何在部署机器上启动它..visual studio自动启动它..

标签: c# wcf wcf-binding wcf-client


【解决方案1】:

通过启用消息记录和跟踪,可以分析服务是否正确启动:

    <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"
        propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="Your_svclog_file_here"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="Your_svclog_file_here"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

在这种情况下,Trace 能够记录“信息”。看到频道的创建很重要。

要分析 svclog 文件,可以使用 Service Trace Viewer - Microsoft Windows SDK,通常在 C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe

【讨论】:

    猜你喜欢
    • 2014-04-12
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多