Is there a way to stop the SignalR server? I have my own SignalR server as a Windows service, but I cannot find a way to stop the server / service.
I tried this, but it does not work - the server continues to listen and prevents the service from stopping.
Alternatively, how can I stop the service altogether by forcibly terminating SignalR?
[edit]:
Most sources I cannot share (copyright / security), but I will do my best:
SignalR init server
Task signalRTask = null; IDisposable SignalR; #region SignalR server init // Kreiraj SignalR server try { cancelTokenSrc = new CancellationTokenSource(); signalRTask = Task.Factory.StartNew(RunSignalR, TaskCreationOptions.LongRunning, cancelTokenSrc.Token); logfile.Info("Starting notifications pool thread..."); //Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. HH:mm:ss ") + "Starting notifications pool thread..."); senderThread = new Thread(delegate() { sender.poolEvents(); }); senderThread.Start(); } catch (Exception ex) { // greška u startanju SignalR servera ServiceEngine.logfile.Info("Error starting SignalR on " + signalr_bind + " with error:" + ex.ToString()); //Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. HH:mm:ss ") + "Error starting SignalR @ {1} with error {0}", ex.ToString(), signalr_bind); } #endregion #region SignalR start // pokreće signalR server public void RunSignalR(object task) { try { logfile.Info("Starting SignalR server on " + signalRBindAddr); SignalR = WebApp.Start(signalRBindAddr); logfile.Info("SignalR server running on " + signalRBindAddr); } catch (Exception ex) { ServiceEngine.logfile.Info("Error starting SignalR: " + ex.ToString()); } //Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. HH:mm:ss ") + "SignalR server running on {0}", signalRBindAddr); } #endregion public class Startup { public void Configuration(IAppBuilder app) { var hubConfiguration = new HubConfiguration { }; hubConfiguration.EnableDetailedErrors = true; app.UseCors(CorsOptions.AllowAll); app.MapSignalR(hubConfiguration); } } public void Stop() { try { logfile.Info("Stop called..."); SignalR.Dispose(); cancelTokenSrc.Cancel(); //signalRTask.Dispose(); logfile.Info("SignalR down, exit..."); //Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. HH:mm:ss ") + "SignalR down, exit..."); } catch (Exception ex) { ServiceEngine.logfile.Info(ex.ToString()); } }
When I call Stop (), SignalR continues to listen (clients can connect, the port has the status of “LISTEN” ...), and I can not stop the service.
PS Sorry for the poor formatting and poor English
source share