#1 2014-04-03 12:02:29

DigDiver
Member
Registered: 2013-04-29
Posts: 137

http.sys API v.2

During the installation the Setup program runs exe, which registers the ports in http.sys

After that, the client connects to the server (Server - windows service) via network and all works fine.

After the system restart, the same client connects to the server again and this time it takes toooooo much time to connect. The execution of several methods takes more than a minute.

HttpSysManager.exe shows that the ports are registered.
(
http://+:50888/wps/
http://+:50888/wp/
http://+:50999/svc/
)

If the server and client are installed on the local computer, no problem occurs.

When using http.sys API v.1 the problem does not exist.

The code which is called with the Administrator execution rights during the installation:
 

  ini := TIniFile.Create(DefaultWorkPlace + 'port.ini');
   try
    port    := ini.ReadString('main','port', '50888');
    svcport := ini.ReadString('svc', 'port', '50999');
    ssl     := ini.ReadInteger('main','ssl', 1);
   finally
    ini.Free;
   end;

  delete  := SameText(ParamStr(1),'/DELETE');

  // parameters below must match class function
  //  TTestClientServerAccess.RegisterAddUrl in mORMotHttpServer.pas:
  writeln(REGSTR[delete],' of /wps:' + port + ' for http.sys');
  writeln(REGSTR[delete],' of /wp:'  + port + ' for http.sys');
  writeln(REGSTR[delete],' of /svc:' + svcport + ' for http.sys');

  writeln(THttpApiServer.AddUrlAuthorize('wps',port,    ssl=2, '+',delete));
  writeln(THttpApiServer.AddUrlAuthorize('wp',port,     ssl=2, '+',delete));
  writeln(THttpApiServer.AddUrlAuthorize('svc',svcport, ssl=2, '+',delete));

  AddApplicationToFirewall('Delivery Server',  ExtractFilePath(ParamStr(0)) + 'xxxx.exe');
  AddApplicationToFirewall('Delivery Controller',  ExtractFilePath(ParamStr(0)) + 'yyyy.exe');

  AddPortToFirewall('Delivery Server Port', StrToIntDef(Port,    50888));
  AddPortToFirewall('Delivery Controller Port', StrToIntDef(svcport, 50999));

Creating HTTP server in server application:


 try
  HttpServer  :=  TRootWebServer.Create(port, [WPlaceServer], '+',  useHttpApi, 32, SSL);     // 32
 except
  on e : exception do
   raise Exception.Create('Port: '+ port + ' in use');
 end;

 HttpServer.AccessControlAllowOrigin := '*';

 ....

 HttpServer.AddServer(FSettingsServer, nil, ssl);
 HttpServer.AddServer(FGroupServer, nil, ssl);
 HttpServer.AddServer(FBounceServer, nil, ssl);
 ...

 

Offline

#2 2014-04-03 13:59:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: http.sys API v.2

Are you using the latest version?

There is no need to configure the firewall.
Http.sys is at kernel mode AFAIK

Offline

#3 2014-04-03 18:36:33

DigDiver
Member
Registered: 2013-04-29
Posts: 137

Re: http.sys API v.2

Yes, I'm using version from 01 apr.
Without adding port to the firewall, I did not get to connect to the server. I tried it on windows 8 and windows server 2012

Offline

#4 2014-04-08 12:46:19

DigDiver
Member
Registered: 2013-04-29
Posts: 137

Re: http.sys API v.2

The problem is that calling the Http.CreateRequestQueue function gives the error:

HttpCreateRequestQueue failed: Cannot create a file when that file already exists (183)

It seems the problem is in the generation of the name for CreateRequestQueue.

I added logging:

constructor THttpApiServer.Create(CreateSuspended: Boolean);
var bindInfo: HTTP_BINDING_INFO;

...

    LogToTextFile('fServerSessionID:= ' + Int64ToUtf8(fServerSessionID));
    LogToTextFile('fServerSessionID_BIN:= ' + BinToHexDisplayW(@fServerSessionID,SizeOf(fServerSessionID)));
    LogToTextFile('fServerSessionID_UIN:= ' +  UIntToStr(fServerSessionID));
    LogToTextFile('fServerSessionID_IntToHex:= ' +  IntToHex(fServerSessionID, 16));


    EHttpApiServer.RaiseOnError(hCreateRequestQueue,Http.CreateRequestQueue(
      Http.Version,pointer(BinToHexDisplayW(@fServerSessionID,SizeOf(fServerSessionID))),
      nil,0,fReqQueue));

and saw that BinToHexDisplayW often returns the name for RequestQueue, which already exists in the system.

Probably IntToHex or as mpv suggested UIntToStr is a better choice for the name generation?

As you see BinToHexDisplayW and IntToHex give different results for the same fServerSessionID:

2014-04-08 15:29:38 fServerSessionID:= -72057576321187757
2014-04-08 15:29:38 fServerSessionID_BIN:= FF00000022000055  
2014-04-08 15:29:38 fServerSessionID_UIN:= 18374686497388363859
2014-04-08 15:29:38 fServerSessionID_IntToHex:= FF00000420000053

Offline

#5 2014-04-08 13:19:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: http.sys API v.2

There was indeed an issue!

We just fixed the BinToHexDisplayW() function.
See http://synopse.info/fossil/info/067be43817

Should work as expected now.
Thanks for the feedback.

Offline

Board footer

Powered by FluxBB