RTC Forums

Subscription => Support => Topic started by: brian71us on October 11, 2017, 01:30:16 AM



Title: rtcFileProvider not serving up pages?
Post by: brian71us on October 11, 2017, 01:30:16 AM
Hello,

I pilfered the rtcFileProvider data module from the RTCWebServer demo for my own project. It is a Delphi back end with a TWebBrowser that needs to display web pages served up via a TRtcHttpServer. The web page will then use XMLRPC to talk to the Dephi application behind it.

I've modified the DataModuleCreate constructor as follows:

  folder := 'c:\inetpub\wwwroot\';

  filename := System.IOUtils.TPath.Combine(folder, 'index.html');

  AddContentType('c,pas,asc,txt,ini=text/plain');
  AddContentType('html,htm=text/html');
  ... etc ...

  AddIndexPage(filename);
  AddHost('localhost:8096=' + folder);

The application builds and runs but the web page doesn't show up in the embedded web browser.

When I type this into a web browser...

http://localhost:8096/index.html

I get the text below and the browser just keeps spinning.

Your IP: 127.0.0.1
Server Time: 8:29:37 PM
Connection count: 4
Memory in use: 273.531 MB


Title: Re: rtcFileProvider not serving up pages?
Post by: Star5 on October 11, 2017, 01:48:24 AM
AddHost('*=.\www');
AddIndexPage('index.htm');
AddContentType('c,pas,asc,txt,ini=text/plain');
...
rtcFileProvider.GetFileProvider.ServerLink.Server := RtcHttpServer1;
RtcHttpServer1.ServerPort:='8833';
RtcHttpServer1.Listen(False);

Host writing '*=.\www' or '*=c:\www' or '/up=.\upload'


Title: Re: rtcFileProvider not serving up pages?
Post by: D.Tkalcec (RTC) on October 11, 2017, 09:17:06 AM
1. If you are using an older RTC SDK version, the response you are getting could be from the "TimeProvider" component on the "TFile_Provider" module implemented in the "rtcFileProvider" unit, but ... it could also be from one of your other TRtcDataProvider instances, or your default response to all requests which weren't accepted.

2. The "AddHost" method uses '*' to match all HOST names (ignore the HOST entry). Otherwise, it needs the exact HOST header received from the Browser. For local tests and all Servers hosting one domain, using '*' for the Host should be enough. For example, AddHost('*=c:\inetpub\www') would make all "other" hosts (those not explicitly added with a host name) use the 'c:\inetpub\www' folder as their root.

3. The "AddIndexPage" method expects a File name with a relative path, but you are providing your index file with the absolute path (including drive and full folder path), which might be a reason for the file NOT being found. For example, AddIndexPage('index.html') should work if you place the 'index.html' file into the root folder you've set up with the "AddHost" method (see point 2 above).

In short, if you place all the files you want to make accessible into the "c:\inetpub\wwwroot" folder (including your "index.html" file) and sub-folders, using this set of parameters should do the trick ...

 AddIndexPage('index.html'); // required
 AddHost('*=c:\inetpub\wwwroot'); // required
 AddContentType('html,htm=text/html'); // recommended
 AddContentType('c,pas,asc,txt,ini=text/plain'); // optional

PS. I guess, you have assigned your TRtcHttpServer instance to the "ServerLink.Server" property on the "File_Provider" DataModule, as pointer out by Star5 in his reply (see above).

Best Regards,
Danijel Tkalcec


Title: Re: rtcFileProvider not serving up pages?
Post by: brian71us on October 12, 2017, 02:40:20 PM

I corrected my index page and host and it's working now.  ;D

Thanks, guys!