Skip to content

OnDisconnectedAsync() always getting null as exception on client connection close #21796

@BrennanConroy

Description

@BrennanConroy

Issue moved from SignalR/SignalR#4455


From @aneeshsiva77 on Monday, March 30, 2020 9:01:13 AM

I have SignalR hub which has OnDisconnectedAsync(Exception exception) override the base method. Currently this method will hit on all the disconnected scenarios (Connection stopped from the client side, Browser Closed, Browser Tab closed etc.) But the parameter 'exception' is always null ,
Expected behavior
Exception must has some message instead null

Actual behavior
null exception

Steps to reproduce

public override async Task OnDisconnectedAsync(Exception exception)
{
	var connectionID = Context.ConnectionId;
	// Disconnect by intention
	if (exception == null)
		{
		//User Closed the connection
		} 
	else { 
		//Connection closed unexpectedly 
		}
	await TryStopBroadcast();
	await base.OnDisconnectedAsync(exception);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions