I'm trying to add signalr to the webapi, I create the CucinaHub class:
public class CucinaHub : Hub
{
static ConcurrentDictionary<string, string> _users = new ConcurrentDictionary<string, string>();
#region Client Methods
public void SetUserName(string userName)
{
_users[Context.ConnectionId] = userName;
}
#endregion Client Methods
}
and configure SignalR:
services.AddSignalR();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<CucinaHub>("/cucinahub");
});
Then in Windows form application I use this code to connect with the hub:
_signalRConnection = new HubConnection($"{Properties.Settings.Default.URL}/api", true);
_hubProxy = _signalRConnection.CreateHubProxy("/cucinahub");
_hubProxy.On("GetValvole", async () => await GetValvole());
try
{
//Connect to the server
await _signalRConnection.Start();
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
I get always 404 response code:
Hosting environment: Development Content root path: D:\SwDev\PigsutffHTML\Server\Common\Common.WebApiCore Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:5000/api/signalr/negotiate?clientProtocol=2.1&connectionData=[%7B%22Name%22:%22/cucinahub%22%7D] - - warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect. info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:5000/api/signalr/negotiate?clientProtocol=2.1&connectionData=[%7B%22Name%22:%22/cucinahub%22%7D] - - - 404 0 - 122.4090ms
Where is the error? Thank you