RTC Forums
March 28, 2024, 10:10:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcHttpServer.StopListen issue  (Read 2926 times)
WilliamY
RTC License++
*****
Posts: 23


« on: July 13, 2020, 11:07:03 PM »

HI,

I was just finish upgradng my project to use the latest RealthinClient, Delphi 10.4 Sydney. I had the following codes in a window service OnStop event:

if RtcHttpServer.IsListening then
   RtcHttpServer.StopListen

It took at least 10+ seconds to wait StopListen to be completed,   What was the procedure doing that would take such a long time??   I don't have such issue with v6.04 (the one I had upgraded from).

FYI,  There is no one connect to this window service,  I just did a start service, and then a stop service right after,  It took 10+ seconds to stop,  commented out above codes, everything then went to normal.

Regards,

William

Logged
Star5
RTC Expired
*
Posts: 27


« Reply #1 on: July 14, 2020, 05:27:23 AM »

RtcHttpServer1.StopListenNow(60);
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: July 14, 2020, 06:40:03 AM »

If you are stopping your Server listener with the goal to terminate your Application, make sure to call "StopListenNow" (blocking, waits for the Server listener to actually stop before it continues to the next line of code) instead of "StopListen" (asynchronous, returns immediately, but requires expensive clean-up if the application starts terminating while the Server listener is still active).

"StopListenNow" was introduced in later RTC SDK versions to simplify the shut-down process and avoid all kinds of issues that could be caused by calling "StopListen" shortly before terminating the Application. In some cases, the Application would terminate immediately, while in other cases it would never terminate.

Due to the multi-threaded and event-driven nature of the RTC SDK, some things need to be taken care of before you start terminating your Application (for example, make sure the Server listener has actually been stopped and all the connections are closed with no background threads running), if you want to avoid problems during Application shut-down (like dead-locks, or thread synchronization issues, or asynchronous calls to events implemented on objects which have already been destroyed).
Logged
WilliamY
RTC License++
*****
Posts: 23


« Reply #3 on: July 14, 2020, 03:45:16 PM »

Ah, Thanks for the clarification. Much appreciated.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 17 queries.