2014-04-06 3 views
0

긴 질문에 사과드립니다. 전체 그림을 그려야합니다.SignalR 허브 OnDisconnect가 ObjectDisposedException을 발생시킵니다.

내가 내 서비스 중 하나에 주입 해요 SignalR 허브를 가지고, 여기에 서비스 :

private readonly INotificationRepository _notificationRepository; 
private readonly INotificationHub _notificationHub; 
private readonly IUserRepository _userRepository; 

public NotificationService(INotificationRepository notificationRepository, 
          INotificationHub notificationHub, 
          IUserRepository userRepository) 
{ 
    _notificationRepository = notificationRepository; 
    _notificationHub = notificationHub; 
    _userRepository = userRepository; 
} 

이 내 NotificationHub이 같은 모습입니다 :

[Authorize] 
public class NotificationHub : Hub, INotificationHub 
{ 
    // other stuff here 

    // works - no issues -> Context.User.Identity.Name has a value as expected 
    public override Task OnConnected() 
    { 
     string name = Context.User.Identity.Name; 
     // do stuff with the name ... 
     return base.OnConnected(); 
    } 

    // at random intervals is being trigerred 
    // and Context.User.Identity throws a "ObjectDisposedException" 
    public override Task OnDisconnected() 
    { 
     string name = Context.User.Identity.Name; 
     // do some more stuff with the name ... 
     return base.OnDisconnected(); 
    } 
} 

이 방법입니다 IoC (이 경우 자동 팩스)를 연결합니다.

builder.RegisterType<NotificationService>().As<INotificationService>().InstancePerHttpRequest(); 
builder.RegisterType<NotificationRepository>().As<INotificationRepository>().InstancePerHttpRequest(); 
builder.RegisterType<UserRepository>().As<IUserRepository>().InstancePerHttpRequest(); 
builder.RegisterType<NotificationHub>().As<INotificationHub>().ExternallyOwned(); 

나는 몇 시간 동안 여기에 갇혀 있었지만, 내 종속성을 올바르게 연결하지 않습니다 (평생 범위 측면에서). 그러나 나는 그것을 이해할 수 없다.

편집

난 그냥 크롬에서 테스트했고 작동하는 것 같군 - 예외 만 (내 경우에는 내가 IE11에서 테스트 한) IE에서 발생합니다.

또한 Windows 인증을 사용하고 있습니다 (양식 인증을 사용하는 다른 프로젝트에서이 인증서를 사용했는데 제대로 작동하는 것 같습니다).

버그가 있는지 확실하지 않습니다.

답변

1

나는 많은 것들을 시도하고 나는 클라이언트 측에서 다음을 추가하여이 문제를 해결하기 위해 관리 :이 내가 사용 SignalR의 버전에서 버그가 생각

window.onbeforeunload = function (e) { 
    $.connection.hub.stop(); 
}; 

을 (2.0.3). 여기에 로그인했습니다 : https://github.com/SignalR/SignalR/issues/2972

관련 문제