簡體   English   中英

WCF服務命名管道故障

[英]WCF service named pipe failure

我已經進行了徹底的搜索,找到了解決此問題的幾種方法,但是沒有一個適用。

我有一個Windows Server使用命名管道終結點托管的.NET 4.0 WCF服務。 設置為在啟動時自動啟動。 我有一個使用該服務的客戶端。

重新啟動服務器后,服務將正常啟動,但是客戶端將收到以下錯誤:

1:在net.pipe:// localhost / WCFSQLService /上沒有偵聽終結點的端點可以接受該消息。 這通常是由不正確的地址或SOAP操作引起的。 有關更多詳細信息,請參見InnerException(如果存在)。

2:在本地計算機上找不到管道終結點“ net.pipe:// localhost / WCFSQLService /”。

如果客戶端和服務都重新啟動,問題將自行解決。

正如其他人指出的那樣,Net.Pipe偵聽器適配器正在運行,並且WCF非HTTP激活已檢查:

net.pipe偵聽器適配器

wcf非http激活

我們甚至嘗試將服務設置為延遲啟動,但沒有任何樂趣。 人們可能會認為端點或配置或正常的WCF東西出了問題,但是當服務和客戶端都重新啟動時,一切正常。 此外,這僅在一台計算機上發生。 如有必要,我可以提供端點信息和代碼。

客戶:

NetNamedPipeBinding binding = new NetNamedPipeBinding();
EndpointAddress endpoint = new EndpointAddress(endpointAddress);
ChannelFactory<IWCFSQLService> channel = new ChannelFactory<IWCFSQLService>(binding, endpoint);
IWCFSQLService client = channel.CreateChannel();
// do client calls
channel.Close();

主辦

  class Program
  {
    static void Main(string[] args)
    {
      ServiceBase[] servicesToRun = new ServiceBase[] 
        {
          new WinServiceHost(), 
        };


      ServiceBase.Run(servicesToRun);
    }
  }



  public class WinServiceHost : ServiceBase
  {
    private readonly ServiceManager serviceManager = new ServiceManager();

    protected override void OnStart(string[] args)
    {
      base.OnStart(args);

      serviceManager.OpenHost<MyService>();
    }

    protected override void OnStop()
    {
      base.OnStop();

      serviceManager.CloseAll();
    }
  }

  public class ServiceManager
  {
    private readonly List<ServiceHost> serviceHosts = new List<ServiceHost>();

    public void CloseAll()
    {
      foreach (ServiceHost serviceHost in serviceHosts)
      {
        serviceHost.Close();
      }
    }

    public void OpenHost<T>()
    {
      Type type = typeof(T);
      ServiceHost serviceHost = new ServiceHost(type);
      serviceHost.Open();
      serviceHosts.Add(serviceHost);
    }
  }

配置

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="behaviorConfig" name="MyService">
        <endpoint address="" binding="netNamedPipeBinding" bindingConfiguration="clientNamedPipeBinding"
                  contract="IMyService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost/MyService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netNamedPipeBinding>
        <binding name="clientNamedPipeBinding">
          <readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" />
        </binding>
      </netNamedPipeBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behaviorConfig">
          <serviceMetadata httpGetEnabled="false" httpGetUrl="" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="true" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="SuccessOrFailure" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

也許服務器正在殺死命名管道? 嘗試定期重新打開客戶端上的通道,直到恢復為止。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM