proudmonkey / AutoWrapper

A simple, yet customizable global exception handler and Http response wrapper for ASP.NET Core APIs.
MIT License
677 stars 82 forks source link

signalr error #95

Closed mansai closed 3 years ago

mansai commented 3 years ago

Failed to start the connection: Error: None of the transports

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Solution1.WebAPI v1")); }

        app.UseHttpsRedirection();
        app.UseApiResponseAndExceptionWrapper();//Delete this line is ok
        app.UseRouting();

        app.UseCors("LimitRequests");

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapHub<ChatHub>("/api2/chathub");
        });
    }

image

image image

mansai commented 3 years ago

Solution1.WebAPI.zip

proudmonkey commented 3 years ago

Interesting. I haven't tried using AutoWrapper in combination of APIs and SignalR. Have you tried setting IsApiOnly to false and set the WrapWhenApiPathStartsWith options?

mansai commented 3 years ago

app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { ShowStatusCode = true, IsApiOnly = false, BypassHTMLValidation = true, WrapWhenApiPathStartsWith = "/api2/chatHub/negotiate" });

is error I custom a OptionBase:IgnorePath app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { ShowStatusCode = true, IsApiOnly=false, BypassHTMLValidation=true, IgnorePath = "/api2/chatHub/negotiate" });

Add code: WrapperBase.cs at line 63 var path = context.Request.Path.Value; if (_options.IgnorePath!=null && _options.IgnorePath== path) { await awm.WrapIgnoreAsync(context, bodyAsText); }

proudmonkey commented 3 years ago

If you've added a custom option to ignore a specific path, you can just return instead of calling WrapIgnoreAsync

mansai commented 3 years ago

Is that so?

if (_options.IgnorePath!=null && _options.IgnorePath== path) { return; }

proudmonkey commented 3 years ago

With the ExcludePath option comes with the latest version, I think this should resolved your issue. See; https://vmsdurano.com/autowrapper-4-5-0-released/