title: SignalR like functionality is not working
body: <p>I have created a like functionality so that a user can like a post in my app. I've read about SignalR and I tried using it so that the number of likes can be automatically updated in real-time whenever a user likes/unlikes a post. However, it does not work, but I also receive no errors. The only message in my console after pressing the like button is:</p>
  <pre><code>Information: WebSocket connected to wss://localhost:44351/hubs/like?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIxIiwidW5pcXVlX25hbWUiOiJnZW9yZ2lhIiwicm9sZSI6WyJNZW1iZXIiLCJBZG1pbiJdLCJuYmYiOjE2MTk0NjQ3NzAsImV4cCI6MTYyMDA2OTU3MCwiaWF0IjoxNjE5NDY0NzcwfQ.1Bwf_Y2QJP_VjRUXaBeqz5sueV6oTIpVlOLU4kOEmLf2Y_hfxJbc5_f4yksY9R45YGz0qPWw-rc10I7pobFJYQ
  </code></pre>
  <p>This is my .net code:</p>
  <pre><code> public class LikeHub : Hub
    {
          private readonly IPostRepository _postRepository;
          private readonly DataContext _context;
          private readonly IUserRepository _userRepository;
  
          public LikeHub(IPostRepository postRepository, DataContext context, IUserRepository userRepository)
          {
              _postRepository = postRepository;
              _context = context;
              _userRepository = userRepository;
          }
  
          public async Task SetLike(int userId, int postId)
          {
              Like l = new Like();
  
              Like temp = _context.Likes.Where(x =&gt; x.PostId == postId &amp;&amp; x.UserId == userId).FirstOrDefault();
  
              if(temp != null)
              {
                  _context.Likes.Remove(temp);
              } else
              {
                  _context.Likes.Add(l);
  
                  l.UserId = userId;
                  l.PostId = postId;
              }
  
              await _context.SaveChangesAsync();
  
              int numOfLikes = _context.Likes.Where(x =&gt; x.PostId == postId).Count();
  
              await Clients.All.SendAsync(&quot;ReceiveMessage&quot;, numOfLikes, postId, userId);
  
          }
     }
  </code></pre>
  <p>And this is my Angular code in the PostsService:</p>
  <pre><code>export class PostsService {
  
    hubUrl = environment.hubUrl;
    private hubConnection: HubConnection;
    likeMessageReceive: EventEmitter&lt;{ numOfLikes: number, postId: number, userId: number }&gt; = new EventEmitter&lt;{ numOfLikes:number, postId: number, userId: number }&gt;();
  
  
    constructor(private http: HttpClient) {}
  
     connectHubs(user: User) { 
        this.hubConnection = new HubConnectionBuilder()
        .withUrl(this.hubUrl + 'like', { accessTokenFactory: () =&gt; user.token, 
        skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets })
        .build();
    
        return  this.hubConnection.start()
                   .then(() =&gt; {
                       this.hubConnection.on('ReceiveMessage', (numOfLikes, postId, userId) =&gt; {
                         this.likeMessageReceive.emit({ numOfLikes, postId, userId });
                       });
                   })
                   .catch(error =&gt; console.log(error)); 
    }
    
    setLike(userId: number, postId: number) {
         this.hubConnection.invoke('SetLike', userId, postId);
    }
    
    closeHubConnections() {
        this.hubConnection.stop();
    }
  }
  </code></pre>
  <p>This is the Angular code in my PostCardComponent, where the like button is:</p>
  <pre><code>export class PostCardComponent implements OnInit {
  
   @Input() post: Post;
    likesSubscription: Subscription;
  
   
    constructor(private postService:PostsService,public accountService:AccountService)
              { this.Login$ = this.accountService.Logged;}
  ngOnInit(): void {
  
      this.likesSubscription = this.postService.likeMessageReceive.subscribe(result =&gt;{
        if (result.postId === this.post.id) {
            this.post.likes.length = result.numOfLikes;
        }
    })
  }
  
  liked(post: Post) {
      const user: User = JSON.parse(localStorage.getItem('user'));
      this.postService.setLike(user.id, post.id);
    }
  }
  </code></pre>
  <p>This is the PostListComponent, where all the posts are:</p>
  <pre><code>export class PostListComponent implements OnInit {
  
    posts: Post[];
    post: Post;
    likesSubscription: Subscription;
    localUser: User;
  
  
    constructor(private postService: PostsService) {}
  
  ngOnInit(): void {
       this.postService.connectHubs(this.localUser);
    }
  
  }
  </code></pre>
  <p>I don't know if the code in <code>this.hubConnection.on()</code> is correct, or if the given parameters are correct. I have also added the LikeHub in my endpoints in the Startup.cs class.</p>