Ole Askeland
Ole Askeland

Reputation: 21

SignalR connection through Azure APIM

The Situation I am using azure apim to proxy requests from client to my web app backend. I am succesfully forwarding the requests through the apim, mainly to hide my backend url in the request from the client. So just to expose the proxy url. However i am struggling with forwarding the signalR connection request through my Azure APIM. I need to do this because the negotiation handshake exposes my backendurl since im directly requesting the backend hub endpoint.

The attempted solution I've tried following this tutorial with LongPolling / ServerSentEvents: https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-howto-work-with-apim. How i am attempting to connect to signalrhub through APIM The APIM endpoint for establishing connection Operations needed as per the tutorial definition of API settings

I've also added the APIM as a ClientEndpoint in the connection string that i use in my backend.

Response from connection request

Any pointers whatsoever would be appreciated, seems like a niche problem and cannot really find any similar problems on the internet. Also any other solutions other than going through APIM would also be great!

Thank you.

Upvotes: 1

Views: 283

Answers (1)

Ikhtesam Afrin
Ikhtesam Afrin

Reputation: 6464

  • I believe, you are trying to invoke the incorrect Url, hence getting 404. If you have followed all the steps given in LongPolling / ServerSentEvents doc then your Url should look like POST https://{apimInstance}.azure-api.net/client/negotiate?hub=chatsamplehub.
  • I have created all the given operations in APIM and then generated the connection string by providing the Url of APIM in client endpoint field.
  • I have below code in index.html file.
var connection = new signalR.HubConnectionBuilder()
  .withUrl("/chat",
      { transport: signalR.HttpTransportType.ServerSentEvents  })
  .build();
  • I have below operations in APIM.

enter image description here

  • I am invoke the APIM negotiate operation as shown below.

enter image description here

Upvotes: 0

Related Questions