c# - SignalR ApplicationUserManager is disposed while using webSockets transport -
i've added signalr existing mvc project , tried use same applicationusermanager mvc load user hub context.
after connection done, call server method this:
var alertshub = $.connection.monitoringhub; $(function() { alertshub.client.processalertchange = function (name, alert) { console.log(alert); }; //start connection $.connection.hub.start().done(function () { console.log("connected, transport = " + $.connection.hub.transport.name); alertshub.server.subscribetomonitor(); }); }); in hub method there call
currentuser = connectedusers.getoradd(this.context.connectionid, usermanager.findbyname(this.context.user.identity.name)); where usermanager property this
protected static concurrentdictionary<string, applicationuser> connectedusers = new concurrentdictionary<string, applicationuser>(); private applicationusermanager _usermanager; public applicationusermanager usermanager { { if (_usermanager == null) { _usermanager = context.request.gethttpcontext().getowincontext().getusermanager<applicationusermanager>(); } return _usermanager; } } protected applicationuser currentuser { get; set; } the problem when websockets transport used i'm getting error 'cannot access disposed object'
signalr: websockets transport connected. initiating start request. signalr: start request succeeded. transitioning connected state. signalr: monitoring keep alive warning timeout of 13333.333333333332, keep alive timeout of 20000 , disconnecting timeout of 300000 connected monitoringhub, transport = websockets signalr: invoking monitoringhub.subscribetomonitor signalr: monitoringhub.subscribetomonitor failed execute. error: cannot access disposed object. object name: 'applicationusermanager'. but! when force serversentevents transport - there no error , works great. why? , how can fixed...
my startup.cs
configureauth(app); // connection or hub wire , configuration should go here var hubconfiguration = new hubconfiguration(); hubconfiguration.enabledetailederrors = true; app.mapsignalr("/sr", hubconfiguration); globalhost.hubpipeline.requireauthentication(); globalhost.configuration.connectiontimeout = timespan.fromseconds(120); globalhost.configuration.disconnecttimeout = timespan.fromseconds(300); globalhost.configuration.keepalive = timespan.fromseconds(10);
Comments
Post a Comment