locked
Unexpected hang hub IHubProxy.Invoke RRS feed

  • Question

  • User-768101397 posted

    We have two web sites on the same physical server, one of which is connected to the second through signalr. This connection is kept already for different notifications.
    We are faced with the fact that by chance (maybe after a couple of days after the restart iis pool) signalr connection may hang forever.
    On stackoverflow http://stackoverflow.com/questions/18657681/signalr-multiple-concurrent-calls-from-client I read that the connection can not be used simultaneously in different threads (ie in our case from the different requests). We did this for a simple connection pool, but it did not solve the problem apparently.

    This code (end-method) is hangs:

            private async Task<T> SendSystem<T>(string method, params object[] parameters)
            {            
                try
                {
                    Guid id = Guid.NewGuid();
                    if (IsNotActive) await Start();
                    if (Logger.Trace.IsDebugEnabled) Logger.Trace.Debug($"MC{_id} start send {method}, {id}");
                    var result = await _systemHub.Invoke<T>(method, parameters);  // hangs there
                    if (Logger.Trace.IsDebugEnabled) Logger.Trace.Debug($"MC{_id} finishSend {method}, {id}");
                    return result;
                }
                catch (Exception ex)
                {
                    Logger.Trace.Error(ex);
                    throw;
                }
            }

    We logged one of this hangs. I cutted out all other connections from connection pool, we interested in MC1 - first connection and c605405e-033e-4785-98bf-ac262f41dee0 - this is internal id from signalr trace. We saw that on 01:56:00,012 - MC1 start send GetOnlineUsers 7a59d5b6-c5e1-4b99-b925-adc1448e6efd (this id - it our request id) and not returned. But this connection after this continue receive pings and callbacks. And finishSend GetOnlineUsers is never logged after this. 

    Number after time in log is thead id

    [2016-12-23 01:55:34,333] [179] - Pool 0,10664 2: got client 1
    [2016-12-23 01:55:34,333] [179] - MC1 start send GetOnlineUsers, 193ee616-0467-40c4-b4c8-0271ead75f79
    [2016-12-23 01:55:34,333] [164] - 22:55:34.3337443 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"R":[147469,117058,2,116752,116908,115925,13846,137422],"I":"840"})
    [2016-12-23 01:55:34,333] [167] - MC1 finishSend GetOnlineUsers, 193ee616-0467-40c4-b4c8-0271ead75f79
    [2016-12-23 01:55:34,333] [167] - Pool 0,10664 2: returned client 1, inUseCount:5
    [2016-12-23 01:55:34,692] [190] - 22:55:34.6925646 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({})
    [2016-12-23 01:55:35,082] [190] - 22:55:35.0826036 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"C":"d-85481753-B,DA|C,0|D,0","M":[{"H":"SystemHub","M":"SystemEventCallback","A":[{"a":1,"b":411368}]}]})
    [2016-12-23 01:55:44,708] [190] - 22:55:44.7081548 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({})
    [2016-12-23 01:55:54,521] [178] - Pool 0,10664 2: got client 1
    [2016-12-23 01:55:54,536] [178] - MC1 start send GetUserMessages, 07da4655-68d3-4b52-97c6-2455c21de3c7
    [2016-12-23 01:55:54,536] [190] - 22:55:54.5366196 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"R":[{...}"}],"I":"841"})
    [2016-12-23 01:55:54,536] [185] - MC1 finishSend GetUserMessages, 07da4655-68d3-4b52-97c6-2455c21de3c7
    [2016-12-23 01:55:54,536] [185] - Pool 0,10664 2: returned client 1, inUseCount:5
    [2016-12-23 01:55:54,723] [196] - 22:55:54.7238284 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({})
    [2016-12-23 01:56:00,012] [196] - 22:56:00.0124539 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"C":"d-85481753-B,DB|C,0|D,0","M":[{"H":"SystemHub","M":"SystemEventCallback","A":[{"a":4}]}]})
    [2016-12-23 01:56:00,012] [196] - 22:56:00.0124539 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"C":"d-85481753-B,DC|C,0|D,0","M":[{"H":"SystemHub","M":"SystemEventCallback","A":[{"a":5}]}]})
    [2016-12-23 01:56:00,012] [156] - Pool 0,10664 2: got client 1
    [2016-12-23 01:56:00,012] [156] - MC1 start send GetOnlineUsers, 7a59d5b6-c5e1-4b99-b925-adc1448e6efd
    [2016-12-23 01:56:04,739] [196] - 22:56:04.7394519 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({})
    [2016-12-23 01:56:06,361] [196] - 22:56:06.3619176 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({"C":"d-85481753-B,DD|C,0|D,0","M":[{"H":"SystemHub","M":"SystemEventCallback","A":[{"a":1,"b":411368}]}]})
    [2016-12-23 01:56:14,755] [190] - 22:56:14.7550744 - c605405e-033e-4785-98bf-ac262f41dee0 - WS: OnMessage({})
    ....

    GetOnlineUsers method - very simple and can't hang - it simple returned keys list from concurrent dictionary on server side.

    I have two questions:
    1) Is it possible concurrent use one connection signalr from one site to another or parallel sending is not allowed and connection pool is right solution?
    2) What can can we do with this hangs?

    Friday, December 23, 2016 10:22 AM

All replies