Search code examples
azurehttpswebsocketazure-web-app-servicesignalr-2

SignalR Core app deployed to Azure doesn't work over https


I've created a simple web app with SignalR Core and deployed it into Azure, and enabled websockets for app service.

But after that when I try to access it using https:// it returns HTTP ERROR 500.

Any idea what is wrong? Do I need to set anything else in settings to make it work over https?


Solution

  • when I try to access it using https:// it returns HTTP ERROR 500.

    Please make sure your SignalR app could run without any error before publishing it to Azure website. I have a sample app that works fine on local and Azure, please refer to it.

    Project.json

    {
      "dependencies": {
        "Gray.Microsoft.AspNetCore.SignalR.Server": "0.2.0-alpha1",
        "Microsoft.AspNetCore.WebSockets": "1.0.1",
        "Microsoft.AspNetCore.Diagnostics": "1.0.0",
        "Microsoft.AspNetCore.Mvc": "1.0.1",
        "Microsoft.AspNetCore.Razor.Tools": {
          "version": "1.0.0-preview2-final",
          "type": "build"
        },
        "Microsoft.AspNetCore.Routing": "1.0.1",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
        "Microsoft.AspNetCore.StaticFiles": "1.0.0",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0",
        "Microsoft.Extensions.Logging": "1.1.1",
        "Microsoft.Extensions.Logging.Console": "1.1.1",
        "Microsoft.Extensions.Logging.Debug": "1.1.1",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
        "Microsoft.NETCore.App": {
          "version": "1.0.1",
          "type": "platform"
        },
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
        "Microsoft.AspNet.SignalR.Client": "2.2.1"
      },
    
      "tools": {
        "BundlerMinifier.Core": "2.0.238",
        "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
      },
    
      "frameworks": {
        "netcoreapp1.0": {
          "imports": [
            "dotnet5.6",
            "portable-net45+win8"
          ]
        }
      },
    
      "buildOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true
      },
    
      "runtimeOptions": {
        "configProperties": {
          "System.GC.Server": true
        }
      },
    
      "publishOptions": {
        "include": [
          "wwwroot",
          "**/*.cshtml",
          "appsettings.json",
          "web.config"
        ]
      },
    
      "scripts": {
        "prepublish": [ "bower install", "dotnet bundle" ],
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
      }
    }
    

    Startup class

    public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddMvc();
        services.AddSignalR(options=> {
            options.Hubs.EnableDetailedErrors = true;
        });
    }
    
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();
    
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }
    
        app.UseStaticFiles();
        app.UseWebSockets();
        app.UseSignalR();
    
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
    

    Website Chat page

    enter image description here

    Besides, this article is about “Getting started with SignalR Core”, please refer to it.