Currently I'm studying SignalR for ASP.NET Core web project, I use ASP.NET Core as a server for SignalR and web clients use SignalR Javascript Client. I'm making a chat app that will return some message when the client invoke function from the server. Here's my Javascript client function:
this.hub.invoke(method, data)
.then((res)=>{ alert(res);})
.catch(err=> alert(err));
public async Task<IActionResult> joinRoom(string roomId)
{
Console.WriteLine(roomId);
return new OkObjectResult("Ok");
}
Problem:
Invocation success, Console on the server side wrote the roomId
However, the client side's Promise.then/Promise.catch didn't work.
When I close the server, there're multiple error on client side that said Invocation has been canceled due to the connection was closed.
My SignalR version is 1.0.3
Really, I can't find out what's the reason. I hope you can help me, please... I also tried with return a string on the server side but it didn't work too.