简体   繁体   中英

Debugging doesn't run sometimes for signalr project in Visual Studio

I'm developing a web application which has a signalr implementation.

I develop it with Visual Studio 2015 community version. When clicked to debug button it opens in Google Chrome browser, but sometimes the page isn't loaded. Then I have to shut down and restart the visual studio.

It runs then normally. After a while it repeats the problem.

I have an hub class in server side;

public class PaylasimHub:Hub
{
    public void Send(string update)
    {

        Clients.Group(senderUye.Eposta).broadcastMessage(update);

    }

    public override Task OnConnected()
    {


        string email= Context.User.Identity.Name;
        Groups.Add(Context.ConnectionId, email);

        return base.OnConnected();
    }

    public override Task OnDisconnected(bool stopCalled)
    {
        string email = Context.User.Identity.Name;
        Groups.Remove(Context.ConnectionId, email);
        return base.OnDisconnected(stopCalled);
    }
}

and at client side start it with this;

$.connection.hub.start();
$.connection.hub.logging = true;

Why this kind of a thing could happen?

I found that if I stopped the debugging session without closing the Signalr hub connection from the client side (ie $.connection.hub.stop()), I would experience all sorts of problems. It would take the debugger forever to stop and I would sometimes get a message about debugger instability. Sometimes the debugger would not restart as well. If I close the connections properly, everything works fine.

My theory is that the problem is with IIS running Signalr which, for whatever reasons, does not terminate properly when it is still trying to maintain the open Signalr connections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM