簡體   English   中英

Service Fabric - Remoting Listener和Communication Listener不能同時工作

[英]Service Fabric - Remoting Listener and Communication Listener not working simultaneously

我是Service Fabric的新手,在我的練習中,我做了一個可靠的無狀態服務,在RunAsync中,增加了他的屬性“counter”。 我驗證了我可以通過接口IService公開一個返回此計數器值的方法(通過ServiceProxy從客戶端調用的方法),顯然會覆蓋CreateServiceInstanceListeners並添加CreateServiceRemotingListener。 然后我嘗試添加另一個自定義通信偵聽器SS1ServiceEndpoint(偵聽指定端口7080):

<Endpoint Name="RemoteListener" />
<Endpoint Name="SS1ServiceEndpoint" Protocol="http" Port="7080" Type="Input" />

但服務最初拋出

Exception thrown: 'System.ArgumentException' in Microsoft.ServiceFabric.FabricTransport.dll

然后調用自定義偵聽器的OpenAsync方法的次數越來越多,並且在每次調用之后會拋出另一個異常:

Exception thrown: 'System.ObjectDisposedException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
Exception thrown: 'System.Fabric.FabricElementAlreadyExistsException' in 
System.Fabric.dll
Exception thrown: 'System.ArgumentException' in 
Microsoft.ServiceFabric.FabricTransport.dll

如果我在CreateServiceInstanceListeners中刪除CreateServiceRemotingListener,則服務啟動,我可以從偵聽端口上的瀏覽器調用它。

我的問題是:不支持多個聽眾嗎? 我沒有嘗試過兩個自定義監聽器(在不同的端口上)。

支持多個偵聽器,但您必須為偵聽器提供名稱,否則該名稱是可選的。 嘗試在CreateServiceInstanceListeners為偵聽器添加名稱。

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[]
    {
        new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context), "RemotingListener"),
        new ServiceInstanceListener(context => new CustomListener(), "CustomListenerName")
    };
}

暫無
暫無

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

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