I have SignalR Client Hub Connection and call InvokeAsynch method and server receives message in correct way. Then i return response and client hangs on InvokeAsync.
In Asp.Net Signalr (neither core nor abp) this manner works but there was CallAsync method in HubProxy instead InvokeAsync in HubConnection.
Client side:
public async Task<bool> EdytujObszar(int elementId, int obszar)
{
bool res = await Connection.InvokeAsync<bool>(EnumTools.GetDescription(MessageTypeEnum.EdytujObszar), elementId, obszar);
return res;
}
Server side:
public class MyHub : OnlineClientHubBase, ITransientDependency, IMyHub
{
private readonly IHubContext<MyHub> _hubContext;
(...)
public bool EdytujObszar(int elementId, int obszar)
{
bool result;
(some logic)
return result;
}
I would like to receive response from server but InvokeAsync hangs forever. Using On method on client side to subscribe on message does not fulfil my expectations in this scenerio.
6 Answer(s)
-
0
Hi,
You should do it like this https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Chat/SignalR/SignalRChatCommunicator.cs#L46. You can check SignalRChatCommunicator.cs in your project.
-
0
Error 404 when trying to open your URL.
-
0
Hi @aprsystem, you need to login with your github account associated with your aspnetzero license to view url.
you can do it at https://aspnetzero.com/LicenseManagement
-
0
-
0
OK. I opened that page. But it is not anticipated approach. As i wrote:
- Client send message to server and wait for response (or not if is async)
- Server receives message, handle it and send response
- Client must receive message from server and receive method (same which sent) unlocks (or not if is async)
Client must not wait for messages byc subscription approach.
-
0
Hi @aprsystem
Couldn't understand the problem, sorry.
If you want to use something works asynchronous, you can use SignalR. If you want something synchronous, you can directly call an AppService method.