SignalR Blocking Issue: Infinite Wait When Calling a Method from Client
Hello here is a Hub I implemented, the goal is to make a board game turn system, the most important part is in the method
LaunchGame
.
I ask in the while loop two question "PiocheRequest" and "CoordRequest".
The functions works well for the first 2 player in the loop. But at the third, the client send it successfully but the server is blocked and don't trigger PiocheResponse
.
What I tried: Using locks, mutexes because I think it's a threading problem but it didn't gave me a different result.
Many thanks in advance,5 Replies
You have the full code of. my lobby if you want to try in local
Here is how I call from client the methods in general: (Here
PiocheRequest
)
Here is a mermaid diagram of the logic I really needOk, I did an update of my code, with advice of @TeBeCo I used a Singleton and DI approach so here is my code re-written:
But I need to order the sendings of request to the client.
I thought about a Queue is this a good approach ?
Ok I have added the logic and at the third turn during my
PiocheRequest
the server is blocked:I don't understand why it's only happening at the third turn
Ok I found the blocking issue:
I have a blocking problem here
After the
await this._hubContext.Clients.Client(connectionId).SendAsync("PiocheRequest", "Veuillez choisir la tuile à piocher (Centre ou Defausse)", requestId);
it's blockingHere is my new code in a github repo:
https://github.com/mehdi-arch/okeygameserver
GitHub
GitHub - mehdi-arch/okeygameserver
Contribute to mehdi-arch/okeygameserver development by creating an account on GitHub.