1

I am trying to connect my Excel Add In to Azure SignalR. I already connected a WPF app - but apparently AspNet Core is not supported in Office Add Ins (getting a DisposeAsync not implemented exception) so i am using the assembly Microsoft.AspNet.SignalR.Client instead.

My code so far:

var query = new Dictionary<string, string>();
query.Add("version", "1.0");
query.Add("Authorization", GenerateAccessToken());
query.Add("hub", _hubName);

connection = new HubConnection(_endpoint, query);
connection.Headers.Add("Authorization", "Bearer " + GenerateAccessToken());
hubProxy = connection.CreateHubProxy(_hubName);

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

connection.Start().Wait();

Executing "connection.Start().Wait()" gives my the following error:

HttpClientException: StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: 
{
  Connection: keep-alive
  Strict-Transport-Security: max-age=15724800; includeSubDomains
  Date: Sun, 25 Jun 2023 18:47:53 GMT
  Content-Length: 146
  Content-Type: text/html
}

The _endpoint is "https://(me).service.signalr.net" replacing (me) with the correct name.

The odd thing is when looking in fiddler i get code 200 with the following call from the WPF app:

POST https://<me>.service.signalr.net/client/negotiate?hub=default&negotiateVersion=1 

When i run the code above it gives me:

GET https://<me>.service.signalr.net/signalr/negotiate?clientProtocol=2.1&connectionData=%5B%7B%22Name%22:%22default%22%7D%5D&version=1.0&Authorization=(access_token.....)

I dont know how to change the endpoint (from signalr to client) or the method. I cannot put parameters on the endpoint without it throwing an exception. If i fill out the query list i seems like a wrong endpoint.

I cannot find any good resources for connecting (including the authorization) to Azure SignalR without AspNet Core.

Any help would be greatly appreciated!

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Stig
  • 31
  • 1
  • 6
  • Hope this help [Git](https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-signalr/signalr-howto-troubleshoot-guide.md) – Sampath Jun 26 '23 at 05:51
  • Office web add-ins act like a regular static web application. As soon as you implement that feature in the web application you can do that for Office add-ins. – Eugene Astafiev Jun 26 '23 at 16:26

0 Answers0