#1 2017-01-05 07:27:25

wangming
Member
Registered: 2016-07-17
Posts: 24

THttpApiServer server port occupied by the problem

I used examples 09 - HttpApi web server wrote a small application and found that as long as the use of the port, IIS can not be used, do not know why, please help me, thank you

constructor TPubRestServer.Create(const Path: TFileName;ListenPort: string);
begin
  FListenPort := ListenPort;
  fServer := THttpApiServer.Create(false);
  fServer.AddUrl('',FListenPort,false,'+',true);
  fServer.RegisterCompress(CompressGZip);
  fServer.OnRequest := Process;
  fPath := IncludeTrailingPathDelimiter(Path);
  FIRSQL := TServiceRemoteSQL.Create;
  FPostRequestCount := 0;
  FGetRequestCount := 0;
end;

destructor TPubRestServer.Destroy;
begin
  fServer.Free;
  inherited;
end;

Offline

#2 2017-01-05 07:50:27

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: THttpApiServer server port occupied by the problem

Try use a different port other than the one (80 by default) used by ISS.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2017-01-05 07:58:53

wangming
Member
Registered: 2016-07-17
Posts: 24

Re: THttpApiServer server port occupied by the problem

THttpApiServer monitor which port, which port IIS can not be used, I have tested the three ports, and do not know how to lift the restrictions, not been listening to the port THttpApiServer, are normal

Offline

#4 2017-01-05 21:57:21

igors233
Member
Registered: 2012-09-10
Posts: 241

Re: THttpApiServer server port occupied by the problem

THttpApiServer internally uses http.sys to facilitate listening, IIS also uses http.sys so it's possible for both of them to use same port and at the same time, you only need to make sure they are registered with unique urls.
Note that you need to have admin rights to register your app within http.sys, you only need to do it once (during setup or later if you change your url).
For example, I have this within my create method:

FRegisteringMode := SameText(ParamStr(1), '/register'); // check if /register argument is passed to app

FServer.AddUrl('root', IntToStr(PrgSettings.ListeningPort), False, '+', FRegisteringMode);

Once I need to install it on a new computer I start admin cmd prompt, go to my app dir and write MyApp.exe /register;

To check if your app is registered you can use simple app at https://httpsysconfig.codeplex.com or you can write "netsh http show urlacl" at command line.

If all is OK, you'll be able to see results when you visit
http://127.0.0.1:MyListeningPort/root

In your example, you're calling addUrl with no url specified, so that might be the problem (if IIS is registered the same way), try something else or unregister IIS.

Offline

#5 2017-01-06 01:18:09

wangming
Member
Registered: 2016-07-17
Posts: 24

Re: THttpApiServer server port occupied by the problem

First of all to thank you for your suggestions, using the http.sysconfig tool and found that there are a lot of used url, if you remove these URLs, IIS can use these ports, and there is no way out in the APP when removed These URLs, can give advice, very grateful

Offline

#6 2017-01-06 03:41:44

igors233
Member
Registered: 2012-09-10
Posts: 241

Re: THttpApiServer server port occupied by the problem

wangming wrote:

First of all to thank you for your suggestions, using the http.sysconfig tool and found that there are a lot of used url, if you remove these URLs, IIS can use these ports, and there is no way out in the APP when removed These URLs, can give advice, very grateful

Sorry, didn't understand, have you got it working or not? If not what is actually happening and what urls are you using and are they registered?

Offline

Board footer

Powered by FluxBB