0

I am making an app separating client and function app and used azure signalR service. I can broadcast message to all clients but cannot send message to individual users. I have found some solutions but they did not worked on my case.

This is my Negotiate function.

    public  class Negotiate : ServerlessHub
{
    [FunctionName("negotiate")]
    public SignalRConnectionInfo GetSignalRInfo(
        [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req,
        [SignalRConnectionInfo(HubName = "chat", UserId = "{headers.x-ms-client-principal-id}")] SignalRConnectionInfo connectionInfo)
    {
     
        return connectionInfo;
    }
 }

And my clinet side connection is :

const apiBaseUrl = 'http://localhost:7071';
const connection = new signalR.HubConnectionBuilder()
.withUrl(`${apiBaseUrl}/api`, {
    headers: {
        "x-ms-client-principal-id": userName
    }
})
.configureLogging(signalR.LogLevel.Information)
.build();

The problem i am facing is i am unable to bind the headers in negotiate.

Manzil
  • 1
  • 3
  • what do you mean by `you are unable ...` ? The header should be available in the httprequest ? – Thomas Aug 04 '22 at 08:25
  • I am not able to send custom headers on HTTP Request. if you see my client side code, this code does not sent the header over my request – Manzil Aug 04 '22 at 09:04

0 Answers0