#1 2022-02-13 17:51:40

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 256

TWebSocketAsyncServer hangs when application is terminated

Delphi 11, win32 target, mormot2

A TRestHttpServer with two TRestServerDB/WebSocketsEnable

when destroying it:
srv.shutdown; (the TRestHttpServer)
srvdb.Free; (one  TRestServerDB)
oper.Free; (second  TRestServerDB)
srv.free;

The TRestHttpServer hangs at file mormot.net.ws.async, line 597,

    // use TWebSocketAsyncConnection.SendDirect for non-blocking socket sending
    if aClientsConnectionID = nil then
      // broadcast to all connected clients
      for i := 0 to fAsync.ConnectionCount - 1 do
        inc(result, ord(TWebSocketAsyncConnection(fAsync.Connection[i]).
           SendDirect(tmp, aFrame.opcode, aTimeOut)))

In the logs,

HTTP: 20220213 17480325 http mormot.rest.http.server.TRestHttpServer(11686740) {"TWebSocketAsyncServerRest(11a9bd80)":{ApiVersion:"WinSock 2.0.514",ServerName:"mORMot2 (Win)",ProcessName:"ppp/srv ppp/oper",SockPort:"0.0.0.0:50480",ServerKeepAliveTimeOut:30000,StatHeaderProcessed:4,StatBodyProcessed:1,StatUpgraded:1,HeadersDefaultBufferSize:2048,Async:{"TWebSocketAsyncConnections(08828170)":{ThreadPoolCount:32,ConnectionCount:1,ConnectionHigh:2,Clients:{"TAsyncConnectionsSockets(111b27c0)":{Count:1,ReadCount:23,WriteCount:23,ReadBytes:3798,WriteBytes:2838962,Total:2}},Server:{"TCrtSocket(0b205d50)":{Server:"0.0.0.0",Port:"50480",RawSocket:1396,TimeOut:10000}},Accepted:2,MaxConnections:7777777,MaxPending:10000}}}} finalized for 2 servers
Warning: 20220213 17480640 warn mormot.net.ws.async.TWebSocketAsyncConnection(112ba170) AfterWrite: unexpected hrsGetCommand]

Thank you in advance

Offline

#2 2022-02-14 09:13:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,386
Website

Re: TWebSocketAsyncServer hangs when application is terminated

Do you use them from WS clients, or regular REST clients?

Offline

#3 2022-02-14 09:15:21

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 256

Re: TWebSocketAsyncServer hangs when application is terminated

ab wrote:

Do you use them from WS clients, or regular REST clients?

forgot to tell
From Regular rest clients is OK. This happens with Websocket clients connected before.

Offline

#4 2022-02-14 09:26:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,386
Website

Re: TWebSocketAsyncServer hangs when application is terminated

Offline

#5 2022-02-14 09:36:20

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 256

Re: TWebSocketAsyncServer hangs when application is terminated

It works OK now. Thanks @ab

Offline

Board footer

Powered by FluxBB