Сбой рукопожатия сигнала R с Azure Service Fabric - PullRequest
1 голос
/ 20 июня 2019

У нас есть клиентское приложение Flutter Dart, которое должно быть интегрировано с Service Fabric Microservice.

Код на стороне клиента не может установить соединение с Сигналом R, и при дальнейшей отладке кода клиента мы видим, что запрос на квитирование не выполняется.

Ниже приведен код клиента:

 Future<void> openChatConnection() async {
    if (_hubConnection == null) {

       //final logger = attachToLogger();
      _hubConnection = HubConnectionBuilder().withUrl(_serverUrl).build();
      _hubConnection.onclose((error) => connectionIsOpen = false);

      _hubConnection.on("OnMessage", _handleIncommingChatMessage);


    }

    if (_hubConnection.state != HubConnectionState.Connected) {
      await _hubConnection.start();
      connectionIsOpen = true;
    }

Ниже приведен код сервера приложения, работающего в Service Fabric:

Startup.cs

public class Startup
    {
        public Startup(IHostingEnvironment env)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder();
                // .SetBasePath(env.ContentRootPath)
                // // .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                // // .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                // .AddEnvironmentVariables();
            this.Configuration = builder.Build();
        }

        public IConfigurationRoot Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();
            services.AddSignalR();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            // if (env.IsDevelopment())
            // {
            //     app.UseDeveloperExceptionPage();
            //     app.UseBrowserLink();
            // }
            // else
            // {
            //     app.UseExceptionHandler("/Home/Error");
            // }

            // app.UseStaticFiles();
             app.UseSignalR(routes =>
            {
        routes.MapHub<NotificationClient>("/Chat");
          });

            app.UseMvc(
                routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");
                });
            app.UseCors();
        }
    }
}

Ниже приведен класс концентратора:

public class NotificationClient : Hub
  {

    #region Consts, Fields, Properties, Events

    #endregion

    #region Methods

    public void Send(string name, string message)
    {
      // Call the "OnMessage" method to update clients.

      Clients.All.SendCoreAsync("OnMessage", new object[]{name, message});

    }
    #endregion
  }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...