Azure SignalR serverless with Azure Functions OnDisconnected not working

Daniel Bordeleau 5 Reputation points

I'm using Azure Funtions with Azure SignalR serverless with and my client is Typescript.

Everything is working fine but I'd like to know when a user is disconnected.

But my OnDisconnected never gets triggered.

I have setup my Upstream :[signalr_extension key found in AzureFunction app keys]

Here is my code :

 signalRHub = new HubConnectionBuilder()
        .withUrl(baseAzureFunctionsUrl, {
            withCredentials: false

My Azure Functions :

    public class SolohubSignalRHub : ServerlessHub

        public Task<SignalRConnectionInfo> NegotiateAsync([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req)
            return NegotiateAsync(new NegotiationOptions() { EnableDetailedErrors = true, IsDiagnosticClient = true });

        public async Task OnDisconnected([SignalRTrigger] InvocationContext invocationContext, ILogger logger)
            Console.WriteLine($"########### {invocationContext.ConnectionId} DISCONNECTED.");
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,039 questions
Azure SignalR Service
Azure SignalR Service
An Azure service that is used for adding real-time communications to web applications.
91 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Ryan Hill 18,636 Reputation points Microsoft Employee

    Hi @Daniel Bordeleau have you added server-side logging to your Function app? If you haven't, I suggest starting there. According to the SignalR Hubs API Guides there are certain conditions where OnDisconnected isn't fired but I'm assuming you're not running into that scenario. So, the idea is to see if we see any of possible sequences listed in the doc. Another thing to do is enable Live Tracing.

    Let me know if the troubleshooting and live tracing doesn't yield any results.

    0 comments No comments