Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
SingalR trying to connect after stop

I'm faced with a strange behavior with signalR. I use it only on one component (vue.js on my ui). When the user navigates to another page (I have spa application) in a destroyed event I'm trying to close the connection. I'm trying two options:

JS: connection.stop();
BE: i catch disconnect message in public override Task OnDisconnectedAsync method

or

JS: connection.invoke('Resource', params);
BE: await Groups.RemoveFromGroupAsync(Context.ConnectionId, "<group name>");

The connection is closed successfully but after some time (~15-20 seconds) the signalR is trying to connect to the server again (but the component is not existing in the elements block). After some time connection was restored but this component is not existing. If i refresh my spa page (with F5) signalR is not trying to connect, but if i open the component with signalR the situation is starting again.

Error in console

Maybe somebody can help me with:

  1. Why is it happening?
  2. How I should disconnect Client and Server
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found it. I've created an empty Disconnect handler and trying to catch the connections.

public override Task OnDisconnectedAsync(Exception? exception) { //breakpoint here; }

Some dev is added another SignalR hub on the application (e.g. another component on UI) and forgets to call close on component unload.

this.connection.stop()

So, don't forget to stop SignalR connections between UI and backend server.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!