How to reset a TRoIndyHttpServer with TRoHttpApiDispatcher?

Using Delphi Alexandria and RemObjects with TRoIndyHttpServer and TRoHttpApiDispatcher configured as below:

// when server starts...
  FRoServerWeb := TRoIndyHttpServer.Create(nil); 
  FROHttpApiDispatcher := TRoHttpApiDispatcher.Create(nil);
  FROHttpApiDispatcher.Path := '/';
  FROHttpApiDispatcher.Server := FRoServerWeb;
  FROServerWeb.Port := 12000;
  FROServerWeb.Active := True;

It works well.
In order to modify its setup remotely, I’ve put other TRoIndyHttpServer component in this project listening to a different port and created another project in order to connect to this server and modify the FRoServerWeb configuration.

So, I can control it remotely.
The problem is when I stop and start FRoServerWeb (to allow setup changing take place).

It complains with the following error: “EOleSysError - COInitialize was not called” when I set := true

I have uROComInit in the project and it is the first unit of the project as required.

Is there a way to stop and start this server remotely without this error?


Can you create a simple testcase that reproduces this error, pls?
You can send it to support@ for keeping privacy.

I’ve suspected (and was correct based on the solution I’ve found) that CoInitialize works for the main thread (and I was trying to stop/start the server in another thread).
So, to solve the problem, I forced the code to run at main thread:

original code:

sError := getServer.resetServer();

The code that works:

TThread.Synchronize(nil,procedure begin sError := getServer.resetServer() ) end );


1 Like