Signalr gives 405 Method Not Allowed

OrenA 21 Reputation points
2022-04-12T13:08:26.77+00:00

Trying to deploy my website to Azure, Signalr gives the following errors on the browser:

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
For this call:

hubs/presence/negotiate?negotiateVersion=1:1
Followed by:

Error: Failed to complete negotiation with the server: Error: The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.: Status code '405'
Here are the endpoints:

app
                .UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                    endpoints.MapHub<PresenceHub>("hubs/presence");
                });

The website works on https, and the urls are defined as follows:

export const environment = {
  production: true,
  apiUrl:'https://vidcallme.azurewebsites.net/api/',
  hubUrl:'https://vidcallme.com/hubs/',
  baseUrl:'/'
};

The api works, the hub doesn't.

Here's the Api web.config

<system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\API.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>

The client is written with Angular

Related: SignalR Error 405 (method not allowed) - Negotiate.

I'm Using .net Core 5.0

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,344 questions
Azure SignalR Service
Azure SignalR Service
An Azure service that is used for adding real-time communications to web applications.
131 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,268 questions
{count} votes

1 answer

Sort by: Most helpful
  1. James Mitchell 0 Reputation points
    2024-06-07T14:45:33.5133333+00:00

    Adding this in case it comes up for anyone else:

    I had a similar problem that was caused because the Url's didn't match.
    In the "app' code snippet you have: endpoints.MapHub<PresenceHub>("hubs/presence");

    But in the javascript "environment" snippet you have:
    hubUrl:'https://vidcallme.com**/hubs/**',

    I assume that the host names are in order, but the path's have to match. Are you adding "presence" to the end of the hubUrl when starting the connection? If not that might be the problem

    0 comments No comments