Service cloth - listener and message listener not working at the same time
I am new to Service Fabric and, im my exercises, I made a robust stateless service that in RunAsync increments its "counter" attribute. I have verified that I can provide, via the IService interface, a method that returns these counter values (a method called by the client via ServiceProxy) by explicitly overriding CreateServiceInstanceListeners and adding CreateServiceRemotingListener. Then I tried to add another custom SS1ServiceEndpoint message listener (which listens on the specified port 7080):
<Endpoint Name="RemoteListener" />
<Endpoint Name="SS1ServiceEndpoint" Protocol="http" Port="7080" Type="Input" />
but the service throws out first
Exception thrown: 'System.ArgumentException' in Microsoft.ServiceFabric.FabricTransport.dll
Then the OpenAsync method of the custom listener is called more and more times, and a different exception is thrown after each call:
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 the CreateServiceRemotingListener in the CreateServiceInstanceListeners the service starts and I can call it from the browser on the listening port.
My question is, are multiple listeners not supported? I have not tried using two custom listeners (on different ports).
source to share
Multiple listeners are supported, but you must provide a name for the listeners, which is otherwise optional. Try adding a name for your listeners in CreateServiceInstanceListeners
.
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context), "RemotingListener"),
new ServiceInstanceListener(context => new CustomListener(), "CustomListenerName")
};
}
source to share