Closed michasacuer closed 5 years ago
From your code, you aren't storing the HubConnection
anywhere. So the Garbage Collector is free to clean it up whenever it wants after Initialize()
is called.
Everything works fine, i didnt know that i cant acces to hub.On
methods. Messages
adding to Notifications
works, but i could not debug it.
I just copy-pasted my stack overflow question from here. I belive its uncommon problem, because yesterday these snippets worked perfectly. In two machines with Visual Studio 2017 and Visual Studio 2019 that code stopped working
I am working on a SignalR Clinet-Server connection. My server is
WebApi Core 2.1
and my client isWPF .NET Framework 4.7.2
.On the client side I have a
singleton
hub service with one Instance to recive messages from server:i initialize it as singleton:
While I'm debugging, on
MainWindowViewModel
im hitting thatHubService
.On
Server
side its look like this.Hub
:Im trigering send message in this way in my controller's methods:
As I wrote before, while I'm debugging my
WebApi
, inClients
I have exactly one connection from myWPF
. When I turn offWPF
,connection count = 0
so connections works perfectly.But when I call
SendAsync()
, I'm not reciving any information inWPF
inhubConnection.On
. Funny thing, yesterday it works perfectly.So, is my thinking about making
HubService
as staticsingleton
is right? If its, why i cant recive messages fromWebApi
bySignalR
when myWPF
is connected to it?I asked something similiar yesterday but i found a solution for it. Yesterday, my methods works, i could hit
hubConnection.On
when i get any message fromWebApi
. My question from yestarday.Injection of
HUb
to controller:And
Startup.cs
onlySignalR
things (i deleted other things not related to signal):Here is connection that i can get it, when my client
WPF
will register his connection: