简体   繁体   中英

Service Fabric - Remoting Listener and Communication Listener not working simultaneously

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).

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")
    };
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM