How to debug SignalR application in Net Core 3.1
- 2020 year: VB.NET ASP.NET Core 3.1 SignalR console tester (Project Template for VS2019) - Download from: [MyServer], [Github], [VisualStudio Marketplace]
- 2020 year: VB.NET ASP.NET Core 3.1 Microservice with typed SignalR Hub (Project Template for VS2019) - Download from: [MyServer], [Github], [VisualStudio Marketplace]
- 2021 year: Use Fiddler as reverse proxy to isolate microservice for trace request from Redux frontend and to Amazon DynamoDB and debug SignalR hub
- 2021 year: Use SqlServiceBroker to send notification with SignalR
Before I start my own application with SignalR in Net core 3.1, I was take existing application in Net Core 2.2 and has try to rebuild to Net Core 3.1. In Net Core 2.2 this application was working fully and fine.
But unexpectedly in Net Core 3.1 I have received a number of error. Some error I can recognized quickly and quickly fix it, but one issue was been hard to me and forced me install to my computer full environment to debug web socket application at common and SignalR especially.
Firstly I have downloaded MX5 browser and hard connect it to Fiddler proxy. Why MX5? Because I don't want change each time proxy setting and any another browser has own purpose in my computer. And MX5 has full set of debugging tools. There is a proxy setting to tune MX5 websocket through Fiddler.
And this is checking MX5 when Fiddler turn off. All working fine and all communication going through Fiddler.
Since than I was received opportunity to trap not only ordinary http 1.1 oh http 2 request, but also WebSocket traffic.
My second browser was been FireFox and I was send socket request from FF to MX5. If I was changed browser or minor version of Microsoft SignalR library, I each time receive new different errors.
What happens? I was been bewildered. In VS I was have a lot of process and in this mode its impossible to understand what happens exactly and where.
Also at a certain moment I have understanding than line 105 in Javascript never be performed independently of any version of SignalR and browser, but why? Because in Net Core 2.2 this application was worked perfectly.
And finally, after a lot of spending time I have found a solution. SignalR in Net Core 3.1 has additional logging and debugging parameters in server !
1: {
2: "Logging": {
3: "LogLevel": {
4: "Default": "Debug",
5: "System": "Information",
6: "Microsoft": "Information",
7: "Microsoft.AspNetCore.SignalR": "Debug",
8: "Microsoft.AspNetCore.Http.Connections": "Debug"
9: }
10: }
11: }
20: public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost
21: .CreateDefaultBuilder(args)
22: .ConfigureLogging(logging =>
23: {
24: logging.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Debug);
25: logging.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Debug);
26: })
27: .UseStartup<Startup>();
81: app.UseAuthentication();
82:
83: //https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.1&tabs=dotnet
84:
85: app.UseRouting();
86: //app.UseAuthorization();
87: app.UseEndpoints(endpoints =>
88: {
89: endpoints.MapHub<ChatHub>("/chatHub" ,options => { options.Transports =
90: HttpTransportType.WebSockets |
91: HttpTransportType.LongPolling; });
92:
93: endpoints.MapHub<AgentHub>("/agentHub", options => { options.Transports =
94: HttpTransportType.WebSockets |
95: HttpTransportType.LongPolling; });
96: });
Since this step I receive error in server log.
And in line 30 you can see an issue what stole my time.
Other debugging method Use SignalRSwaggerGen to create Swagger specification of SignalR hub
|