Skip to content

Improve error messaging for 404s #5350

Open

Description

@analogrelay

Usually a 404 occurs because sticky sessions are not enabled. We should provide a better error message here.

Activity

  1. ptallett commented on Oct 10, 2018

    @ptallett

    Also if the server has a bug and doesn't expose the hub properly, you get an "Error negotiating: error" which makes you think its actually communicated with the server when in fact it hasn't.

    I'd think messing up the hub definition on the server is quite common for newbies.

    Cheers,
    Paul

  2. analogrelay commented on Oct 10, 2018

    @analogrelay
    ContributorAuthor

    Also if the server has a bug and doesn't expose the hub properly

    Can you elaborate on what you mean by "doesn't expose the hub properly"?

  3. mikaelm12 commented on Oct 10, 2018

    @mikaelm12
    Contributor

    I think @ptallett means when you incorrectly configure map hub and the client try to a wrong hub url.
    We get an unexpected status code returned from negotiate: 404.

  4. davidfowl commented on Oct 11, 2018

    @davidfowl
    Member

    There's nothing we can do about that. If you point your client at www.google.com, we don't get a chance to handle it properly. Maybe we could log the mapped hubs at startup and the URL they are bound to. I'm not sure what we could do on the client side besides improve the error message to say we didn't find the negotiate response?

  5. analogrelay commented on Oct 11, 2018

    @analogrelay
    ContributorAuthor

    I think the ask here is to have an error that actually says we got a 404. At the moment I believe we have a very obscure error. That seems entirely legitimate.

  6. davidfowl commented on Oct 11, 2018

    @davidfowl
    Member

    I see. This is across all the clients right?

  7. analogrelay commented on Oct 11, 2018

    @analogrelay
    ContributorAuthor

    The JavaScript client is the one with the worst error messages :). The others are pretty good already.

  8. analogrelay commented on Nov 19, 2018

    @analogrelay
    ContributorAuthor

    The easiest fix here is to detect the kind of 404 we get. Once a 404 is received:

    1. Have the client detect the Connection ID Required error message and throw an error that points to docs on Sticky Sessions. Something like The server does not have a record of the current connection. This usually occurs when you are using multiple server instances and don't have Sticky Sessions enabled. See https://aka.ms/[something] for more information.

    2. If the Connection ID Required message is not in the body, it's a more "standard" 404. Throw an error like A SignalR Hub could not be found at '[url]'.. Usually this will be caused by bad routing configuration.

  9. analogrelay commented on Nov 19, 2018

    @analogrelay
    ContributorAuthor

    We should do this in all the clients. The JS client is the worst because it has no 404 error (it just says "Error"), but the Java and .NET clients could use the detection logic in 1 above.

  10. added this to the 3.0.0 milestone on Dec 17, 2018
  11. added
    area-signalr
    feature-client-net
    feature-client-java
    feature-client-javascript
    on Dec 17, 2018
  12. 37 remaining items

  13. jogibaeratvega commented on Jul 30, 2019

    @jogibaeratvega

    You receive a 404 when your JWT-Token you send in the query param is to large:

    Error during WebSocket handshake: Unexpected response code: 404

  14. added
    affected-few
    severity-nice-to-have
    on Nov 6, 2020
  15. added and removed
    help wanted
    on Oct 28, 2023
  16. added
    help wanted
    and removed on Jan 7, 2026
  17. added theissue type on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewarea-signalrenhancementfeature-client-javafeature-client-javascriptfeature-client-nethelp wantedseverity-nice-to-have

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions