Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure service fabric 我可以在服务结构服务中使用两种不同类型的侦听器吗?_Azure Service Fabric - Fatal编程技术网

Azure service fabric 我可以在服务结构服务中使用两种不同类型的侦听器吗?

Azure service fabric 我可以在服务结构服务中使用两种不同类型的侦听器吗?,azure-service-fabric,Azure Service Fabric,我有一个作为websocket服务器使用的无状态服务。为此,我使用ICommunicationListener。我还想使用ServiceProxy调用此服务的方法。因此,我使用ServiceRemotingListener internal sealed class Stateless : StatelessService, ICommunicationListener, IStatelessServiceInterface { public Stateless(Stat

我有一个作为websocket服务器使用的无状态服务。为此,我使用ICommunicationListener。我还想使用ServiceProxy调用此服务的方法。因此,我使用ServiceRemotingListener

internal sealed class Stateless : StatelessService, ICommunicationListener, IStatelessServiceInterface
{        
    public Stateless(StatelessServiceContext context)
        : base(context){ }      

    protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
    {           
        return new List<ServiceInstanceListener>()
        {
            new ServiceInstanceListener((context) =>this.CreateServiceRemotingListener(context)),
            new ServiceInstanceListener(_ => this)
        };
    }.....
内部密封类无状态:无状态服务、ICommunicationListener、IStatelessServiceInterface
{        
公共无状态(无状态ServiceContext上下文)
:base(context){}
受保护的重写IEnumerable CreateServiceInstanceListeners()
{           
返回新列表()
{
新ServiceInstanceListener((上下文)=>this.CreateServiceRemotingListener(上下文)),
新的ServiceInstanceListener(=>this)
};
}.....
所以,当我同时使用这两个侦听器时,在诊断事件中运行应用程序后,我得到一条消息:套接字将关闭。所以websocket不工作

所以我想知道我可以同时使用两种类型的监听器吗?或者我的问题有什么解决方案吗?

这是我的OpenAsync:

public Task<string> OpenAsync(CancellationToken cancellationToken)
{
        EndpointResourceDescription serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint("ServiceEndpoint");
        int port = serviceEndpoint.Port;
        this.listeningAddress = string.Format(CultureInfo.InvariantCulture, "http://+:{0}/{1}{2}", port, this.appRoot, this.webSocketRoot);
        this.publishAddress = this.listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);

        this.Start();
        return Task.FromResult(this.publishAddress);
    }
公共任务OpenAsync(CancellationToken CancellationToken) { EndpointResourceDescription serviceEndpoint=this.serviceContext.CodePackageActivationContext.GetEndpoint(“serviceEndpoint”); int-port=serviceEndpoint.port; this.listengAddress=string.Format(CultureInfo.InvariantCulture,“http://+:{0}/{1}{2}”,端口,this.appRoot,this.webSocketRoot); this.publishAddress=this.ListingAddress.Replace(“+”,FabriRuntime.GetNodeContext().IPAddressOrFQDN); 这个。Start(); 返回Task.FromResult(this.publishAddress); }
能否显示OpenAsync?是否知道套接字关闭的原因?是否配置了防火墙?ServiceManifest的Endpoints部分有什么内容?如果我不使用remotingListener,websocket工作正常。请为问题本身添加更新。OpenAsync仍然很有趣。因此,基本上,您发布的是相同的地址两个侦听器的s和端口?它不会那样工作。至少将具有不同名称和路径的第二个端点添加到第一个实例侦听器和第二个实例侦听器。或者只是在OpenAsync的代码中更改端口。是的。我有一个具有不同名称的第二个端点。但我不理解你的意思告诉:“将两个名称的路径都发送到第一个实例侦听器和第二个实例侦听器”只是输入错误。我的意思是,您需要将名称放入实例侦听器,以便每个侦听器都知道哪个端点属于它。顺便说一下,远程处理的端点具有内部类型,而不是输入,并且使用TCP。我不知道如何将端点名称放入实例侦听器。创建实例时,您不指定端点名称ce侦听器,如果只有一个端点,则必须指定是否有多个端点。