RTC Forums
November 24, 2024, 07:41:54 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Http Server as Windows "NT" Service  (Read 5686 times)
gpsanta
Newbie
*
Posts: 2


« on: October 20, 2010, 06:00:24 AM »

Hello.

I'm trying to do a http server as a Windows service. For testing purposes, I'm just responding to a request to get the date-time of the server computer. The problem I have is that the events of the RtcDataProvider are not being fired. However, I have a timer in the same data module that is being fired properly each second. I searched for some example here about windows services and RTC but I could not find it. The same datamodule works fine if I use it in a "normal" application (not service). Any help will be much appreciated.

Regards.
Logged
gpsanta
Newbie
*
Posts: 2


« Reply #1 on: October 20, 2010, 06:26:12 AM »

Additional information: the server is "listening" because I tested the isListening property and it is "true" but the events of the DataProviders seem to be unreacheable when the service is active. The dataprovider are linked to the server properly; I think the problem have to do with how the service applications works, I have almost null experience with Delphi service applications.

Regards.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: October 20, 2010, 05:31:13 PM »

1) In order to know if your Server listener was started, stopped or if there was an error when trying to start the listener, you have to implement the OnListenStart, OnListenStop and OnListenError events. In the OnListenError event, you will get an exception object with the exception message if the listener could not be started.

2) If your code works inside a DataModule called from a normal Windowed application, it should work the same if you call it from a Service Application. Take a look at the RTC WebServer Demo, which can run as a normal Windowed application or as a Windows Service.

Best Regards,
Danijel Tkalcec
Logged
Andrew.W
RTC License
***
Posts: 43


« Reply #3 on: October 28, 2010, 03:14:12 PM »

If you want to run RTC as a windows service it works perfectly BUT you must have a message pump.

No message pump = not working. Service apps do not have a message pump by default.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: October 28, 2010, 05:38:49 PM »

That's a good point. I completely forgot about that. Thanks.

To have the RTC SDK working in a Service, you will have to set the MultiThreaded property on the TRtcHttpServer component to TRUE. When you do that, the RTC SDK will create a message pump in a separate background thread. If you leave the MultiThreaded property at its default value (FALSE), you will need to create your own message pump if your application is running as a Service.

Best Regards,
Danijel Tkalcec
Logged
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #5 on: November 02, 2010, 06:34:53 PM »

.... I have a timer in the same data module that is being fired properly each second.

It's not clear from your post if the timer of which you speak is a TTimer component, nor is it clear if the timer is just for "quick and dirty" testing.  However, it should be noted that if you intend to use a TTimer component in a service application, it must be created at run time.  You cannot just drop one on a data module and expect it to work correctly.

More details: http://www.aldyn.ru/demos/0001/4.html

--
Kevin Powick
Logged

Linux is only free if your time is worthless
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.027 seconds with 17 queries.