question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to pass information from the client to the hub

See original GitHub issue

Context.GetHttpContext() returns the HttpContext in SignalR mode, but returns null in AzureSignalR mode. Therefore I can’t read any QueryString or custom Http Header values in the OnConnectedAsync() method of the Hub. I’m using the following code to create the connection.

var connection = new HubConnectionBuilder().WithUrl("http://localhost:5000/message?t=TestValue",
                    options => options.Headers = new Dictionary<string, string>
                    {
                        {
                            "X-CustomHeader", "CustomValue"
                        }
                    })
                .Build();
await connection.StartAsync();

Is there any way to pass information from the client to the hub using the AzureSignalR service?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
maxiptahcommented, Aug 21, 2018

Do you have an estimation as to when this fix is going to be deployed? I’m trying to pass an auth0 token to the hub method. This is normally passed as a bearer token in authorization header. However as stated in this post, custom header is not possible because of limitations of JS websocket client which does not allow for it. So I wanted to pass my token as query parameter, but it never reaches my hub. Where should I read the query parameters anyway? From Context.Items? Because my Context does not contain Request property as in the example above, and I’ve installed the nuget package of SignalR just today.

1reaction
xscriptcommented, May 25, 2018

Yes, the headers are not passed through from client to server. We will need some discussion to decide whether to support it. A work around is to create a separate hub method and call this method to send information once the client is connected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Failed to invoke signalR
Since your Hub method is called Send1 and your client calls Send , the method is not found. To fix the issue you...
Read more >
ASP.NET Core SignalR connection troubleshooting
This error is usually caused by a client using only the WebSockets transport but the WebSocket protocol isn't enabled on the server. Response ......
Read more >
Troubleshoot Common DMVPN Issues
This document describes the most common solutions to Dynamic Multipoint VPN (DMVPN) problems.
Read more >
Signalr javascript client example. To avoid using sticky sess
NET SignalR hub from JavaScript client. For information about how to specify a different base URL, see ASP. NET SignalR application using the...
Read more >
Developer Hub - Build Upload Failed - PROCESSING
I am trying to upload a new build of my game through the Meta Quest Developer Hub. I am uploading it to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found