Search code examples
azure-functionssignalrsignalr-service

signalr service azure function CORS works on some machines, fails on others


I've run into an odd situation where my web app is able to connect to signalr service (serverless) through an azure function on most machines, but when I try to connect on my work machine, it does the initial OPTIONS request for function-url.com/negotiate?negotiateVersion=1, but it does not do an OPTIONS request for the hub/actual signalr service immediately after, signalr-service-url.com/client/negotiate?hub=roomfunctions&negotiateVersion=1. And even though the signalr service is, by default, set to accept all domains, it still needs that OPTIONS request or it would fail. All machines that work with my web app do the second OPTIONS request.

Not sure how this can happen... Has anyone else ran into it? Client connection is straightforward, and works on nearly all machines. I've also got a separate signalr application that has nearly the same architecture and setup, and it works on the work machine.

Machine that isn't working: not working Machine that is working:
working

Client connection:

  let conn = new signalR.HubConnectionBuilder()
    .withAutomaticReconnect()
    .withUrl(url, {
      headers: {
        'x-ms-signalr-user-id': user.id,
      },
    })
    .build()

  conn.onclose(() => {
    console.log('signalr connection closed')
  })

  conn.onreconnecting(() => {
    console.log('signalr reconnecting')
  })

  conn.onreconnected(() => {
    console.log('signalr reconnected')
  })

  await conn.start()

Solution

  • Ach. It was Adblock. I have the same version and settings on both machines, so not sure why one machine blocks it---but there we go.