Reputation: 51
I'm a newbie on Service Fabric and, im my exercises, I've done a Reliable Stateless Service that, in RunAsync, increments his attribute "counter". I verified that I can expose via interface IService a method that returns this counter values (method called from a client via ServiceProxy), obviously overriding CreateServiceInstanceListeners and adding CreateServiceRemotingListener. Then I tried to add another custom communication listener SS1ServiceEndpoint (that listen on a specified port 7080):
<Endpoint Name="RemoteListener" />
<Endpoint Name="SS1ServiceEndpoint" Protocol="http" Port="7080" Type="Input" />
but the service throws initially
Exception thrown: 'System.ArgumentException' in Microsoft.ServiceFabric.FabricTransport.dll
Then the OpenAsync method of the custom listener is called more and more times and after each call another exception is thrown:
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
If I remove CreateServiceRemotingListener in CreateServiceInstanceListeners, the service starts and I can call it from browser on the listening port.
My question is: are multiple listeners not supported? I've not tried with two custom listeners (on different port).
Upvotes: 5
Views: 1365
Reputation: 731
Multiple listeners are supported, but you have to provide a name for the listeners, which is otherwise optional. Try adding a name for your listeners in your CreateServiceInstanceListeners
.
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context), "RemotingListener"),
new ServiceInstanceListener(context => new CustomListener(), "CustomListenerName")
};
}
Upvotes: 6