signalR Azure : url request to start the negociation is empty

Samy 1 Reputation point
2022-12-11T15:02:38.093+00:00

Hello,
I used signalr to communicate the server to client application.
I have an issue when I deployed on the server.

The request used for the negotiation is empty (see print screen and in the code is connect.start()). But the url is not empty when I put the debug information. You can see in the picture baseurl contain the value in the configuration string. :

269355-image.png

The code to start the connexion.

const options: IHttpConnectionOptions = {  
    accessTokenFactory: async () => {  
  
      const request = {...loginRequest,  
        account: accounts[0]};  
      var token = await instance.acquireTokenSilent(request);  
      return token.accessToken;  
    },  
    transport: HttpTransportType.WebSockets   
  };  
  
 const connect = new HubConnectionBuilder()  
        .withUrl(process.env.NEXT_PUBLIC_SIGNALR_URL!,options)  
        .configureLogging(LogLevel.Debug)  
        .withAutomaticReconnect()  
        .build();  
  
    console.log("signalR connection")     
  
console.log("baseUrl:", connection.baseUrl)  
      if(!connect .baseUrl)  
        return;  
  
      connect   
        .start()  
        .then(() => {  
          connection.on("target", (message) => {  
            let obj: T = JSON.parse(message);  
              
            setMessage(obj);  
          });  
        })  
        .catch((error) => console.log("signalR:", error));  

The client application is done in react. So When I launch the application locally, the negotiate step can be done with the correct url.

269318-image.png

I configure the CORS to open the url. The configuration in Azure contains the url because I put the url in the console log.

Azure SignalR Service
Azure SignalR Service
An Azure service that is used for adding real-time communications to web applications.
147 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 21,736 Reputation points Microsoft Employee
    2022-12-12T11:34:50.287+00:00

    @Samy Thank you for reaching out to Microsoft Q&A, apologize for the inconvenience caused on this. Try look at the network logs instead of reading the console logs since the network logs have the actual HTTP requests going out.

    Refer to this troubleshooting documentation to troubleshoot connectivity and message delivery issues in SignalR.

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.