locked
Aspnetcore Signalr: No client method with the name 'xxx' found. RRS feed

  • Question

  • User-920806005 posted

    Server side code:

    public Task IngressoGruppo(string nomegruppo)
            {
                return Groups.AddAsync(Context.ConnectionId, nomegruppo);
            }
    
            public Task UscitaGruppo(string nomegruppo)
            {
                return Groups.RemoveAsync(Context.ConnectionId, nomegruppo);
            }
    
            public void MessaggioGruppo(string mittente, string nomegruppo, string messaggio)
            {
                Clients.Group(nomegruppo).SendAsync("MessaggioGruppo", mittente, messaggio);
            }

    Client side code:

    this._hubConnection
        .invoke('IngressoGruppo', '12')
        .then(() =>{
                  this._hubConnection
                  .invoke('MessaggioGruppo', 'Alex', '12', 'Hello, how are u')
                  .then(() =>{
                    this._hubConnection
                    .invoke('UscitaGruppo', '12')
                    .then(() =>{
                     
                    }
                  )
                    .catch(err => console.error(err));
                  })
                  .catch(err => console.error(err));
          
    
        })
        .catch(err => console.error(JSON.stringify(err)));

    After I join the group, I get the error: No client method with the name 'MessaggioGruppo' found.

    How can I fix it?

    Thursday, May 3, 2018 9:43 PM

All replies

  • User61956409 posted

    Hi Pasto92,

    the error: No client method with the name 'MessaggioGruppo' found.

    Please share the definition of your client method “MessaggioGruppo”, besides, I’d like to know if you can call other client functions/methods from hub method.

    With Regards,

    Fei Han

    Friday, May 4, 2018 9:14 AM
  • User-920806005 posted

    I get this error with this call: 

    .invoke('MessaggioGruppo', 'Alex', '12', 'Hello, how are u')

    Which means that in server side I'd like to have a function called MessaggioGruppo, and here it is:

    public void MessaggioGruppo(string mittente, string nomegruppo, string messaggio)
            {
                Clients.Group(nomegruppo).SendAsync("MessaggioGruppo", mittente, messaggio);
            }

    Is it a bug? I think the code is right

    Friday, May 4, 2018 9:41 AM
  • User61956409 posted

    Hi Pasto92,

    Clients.Group(nomegruppo).SendAsync("MessaggioGruppo", mittente, messaggio);

    I know you call client function “MessaggioGruppo” from your hub method using above code, but you do not share us the relevant code of client function “MessaggioGruppo”, so I suggested you post the definition of that client function.

    With Regards,

    Fei Han

    Friday, May 4, 2018 9:49 AM
  • User-920806005 posted

    I can't understand.

    I posted all the code. I invoke "MessaggioGruppo" and then i leave group by invoking "UscitaGruppo". There is no further code for client function "MessaggioGruppo".

    Friday, May 4, 2018 10:58 AM
  • User-920806005 posted

    Edit: The code works, in fact the message is sent correctly by sender and received correctly by receivers of the group.

    I can't understand why I get warning message even if everything works.

    Any ideas?

    Sunday, May 6, 2018 11:21 AM
  • User1653303101 posted

    You probably have another function listening from the same hub but with different name. That way, the server sends the data to the group, but you will get the error for every receiver connected to this connection, without implementing the called function.

    I hope this helps

    Tuesday, October 15, 2019 12:19 PM