Closed ygr757326 closed 3 weeks ago
That's strange, I will take a look at this problem. That would be great if you have a unit test to reproduce this problem.
Good morning
I had same problem yesterday...
In my cenario i throw some exceptions on Command - ExecuteAsync.
2024-09-21 23:24:53.234 -03:00 [ERR] Session[893c4fbd-f327-4683-aa55-1f4c32183aaa]: session exception.
SuperSocket.PackageHandlingException1[SuperSocket.WebSocket.WebSocketPackage]: Session 893c4fbd-f327-4683-aa55-1f4c32183aaa got an error when handle a package. ---> System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count. at System.Threading.SemaphoreSlim.Release(Int32 releaseCount) at SuperSocket.Connection.PipeConnectionBase.SendAsync[TPackage](IPackageEncoder
1 packageEncoder, TPackage package, CancellationToken cancellationToken)
at GerenciadorFacial.Commands.RegistrarEquipamento.ExecuteAsync(EquipamentoSession session, CustomDataPackage package, CancellationToken cancellationToken) in C:\dev\<>\<>\<>\Commands\RegistrarEquipamento.cs:line 32
at SuperSocket.Command.AsyncCommandWrap4.ExecuteAsync(TAppSession session, TPackageInfo package, CancellationToken cancellationToken) at SuperSocket.Command.CommandMiddleware
3.CommandSet1.ExecuteAsync(IAppSession session, TPackageInfo package, CancellationToken cancellationToken) at SuperSocket.Command.CommandMiddleware
3.HandlePackage(IAppSession session, TPackageInfo package, CancellationToken cancellationToken)
at SuperSocket.WebSocket.Server.WebSocketPackageHandler.Handle(IAppSession session, WebSocketPackage package, CancellationToken cancellationToken)
at SuperSocket.Server.PackageHandlingSchedulerBase`1.HandlePackageInternal(IAppSession session, TPackageInfo package, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
@kerryjiang is possible to implement one sample using JsonAsyncCommand ?
Basic basic, only for understand it.
Found the problem and working on a fix.
Pushed a fix.
With this fix, you would get TaskCancellationException in the same situation.
I suggest you check the cancellationToken is triggered before you call SendAsync(*).
if (!cancellationToken.IsCancellationRequested)
await session.SendAsync(xxxx, cancellationToken);
cancellationToken.IsCancellationRequested == true means the connection is closed or is being closed.
@ygr757326 @Helder-Henderson
@kerryjiang is possible to implement one sample using JsonAsyncCommand ?
Basic basic, only for understand it.
@Helder-Henderson Do you use token in async json command? Token allows your client to talk with server in this order: Request A, Request B, Request C, Response C, Response A, Response B.
No no, sorry, I found implementation about JsonCommands on unit tests...
My questions was not related to the issue, sorry !
Released SuperSocket 2.0.0-beta.27 to fix this issue: https://www.nuget.org/packages/SuperSocket/2.0.0-beta.27
MyPackageHandler SendAsync error:Adding the specified count to the semaphore would cause it to exceed its maximum count. System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count. at System.Threading.SemaphoreSlim.Release(Int32 releaseCount) at SuperSocket.Connection.PipeConnectionBase.SendAsync[TPackage](IPackageEncoder`1 packageEncoder, TPackage package, CancellationToken cancellationToken)