You are not logged in.
Hello:
I'm trying to connect 3 PC with Win 7 between them. One will have the server and will work as client too like the others.
Trying to use example with THttpApiServer, it work great in Win 10. In the Pc with Server/Client functions, it works ok too, but the others two doesn't see the server.
This is the Server code
procedure TForm16.SetServerBtnClick(Sender: TObject);
begin
if SetServerBtn.Caption = 'Activar' then
begin
FileListBox1.Enabled := false;
SetServerBtn.Caption := 'Desactivar';
Props := TSQLDBSQLite3ConnectionProperties.Create(FileListBox1.FileName, '', '', 'password');
try
fProps := Props;
Conn := fProps.ThreadSafeConnection;
if not Conn.Connected then
Conn.Connect;
FServer := THttpApiServer.Create(false);
FServer.AddUrl('', PortTxt.Text, false, '+', true);
FServer.RegisterCompress(CompressDeflate);
FServer.OnRequest := Process;
FServer.Clone(31);
try
Memo1.Lines.Add('Servidor activo en http://' + ServerURLTxt.Text + ':' + PortTxt.Text + '/' + NL +
'Base de datos disponible: ' + ExpandFileName(UTF8ToString(Props.ServerName)));
except
// error
Memo1.Lines.Add('Ocurrió un error al mostrar datos de conexión.');
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
end;
except
// error
Memo1.Lines.Add('Ocurrió un error al intentar conectar.');
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
end;
end
else
begin
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
FServer.Free;
Memo1.Lines.Add('Desconectado');
end;
end;
This is the Client code
function TForm16.BuscarSQL(const SQL: RawUTF8): RawUTF8;
var
Http: THttpClientSocket;
begin
Http := OpenHttp(ServerURLTxt.Text, PortTxt.Text);
if Http <> nil then
try
Http.Post('', SQL, TEXT_CONTENT_TYPE);
Result := Http.Content;
finally
Http.Free;
end
else
Result := '';
end;
Locally works great, even using localhost as unique IP.
Last edited by Sapiem (2018-08-02 18:16:23)
Offline
This network don't use DNS.
How check http.sys registration tables?
Offline
ping works
Firewall are disabled or allowed both app.
Indy10 TidHTTP works ok always.
Any lack in my code?
Offline
Ok, I check http.sys tables using:
netsh http show urlacl
And it register and then unregister URl using...
procedure TForm16.SetServerBtnClick(Sender: TObject);
begin
if SetServerBtn.Caption = 'Activar' then
begin
FileListBox1.Enabled := false;
SetServerBtn.Caption := 'Desactivar';
Props := TSQLDBSQLite3ConnectionProperties.Create(FileListBox1.FileName, '', '', 'password');
try
if CheckBox1.Checked then <----- This added
THttpApiServer.AddUrlAuthorize('MyServerRoot', PortTxt.Text, false, '+');
fProps := Props;
Conn := fProps.ThreadSafeConnection;
if not Conn.Connected then
Conn.Connect;
FServer := THttpApiServer.Create(false);
FServer.AddUrl('MyServerRoot', PortTxt.Text, false, '+', true);
FServer.RegisterCompress(CompressDeflate);
FServer.OnRequest := Process;
FServer.Clone(31);
try
Memo1.Lines.Add('Servidor activo en http://' + ServerURLTxt.Text + ':' + PortTxt.Text + '/MyServerRoot/' + NL +
'Base de datos disponible: ' + ExpandFileName(UTF8ToString(Props.ServerName)));
except
// error
Memo1.Lines.Add('Ocurrió un error al mostrar datos de conexión.');
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
end;
except
// error
Memo1.Lines.Add('Ocurrió un error al intentar conectar.');
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
end;
end
else
begin
if CheckBox1.Checked then <----- This added
THttpApiServer.AddUrlAuthorize('MyServerRoot', PortTxt.Text, false, '+', true);
FileListBox1.Enabled := true;
SetServerBtn.Caption := 'Activar';
FServer.Free;
Memo1.Lines.Add('Desconectado');
end;
end;
And neither work....
Last edited by Sapiem (2018-08-07 18:09:35)
Offline
Sometimes urlacl contains several records with conflicts. May be you have IIS apps on this host, or register several urls using mormot. Remove all records about your port, when register to the host name, not to the +. If indy works, then problem is in http.sys
Offline
Working behind a proxy can it be related to this problem?
Offline
Please, any solution? I tried a lot of variant and nothing...
When I run netsh http show urlacl I get this:
Dirección URL reservada : http://+:8995/MyServerRoot/
Usuario: \Everyone
Escuchar: Yes
Delegar: Yes
SDDL: D:(A;;GA;;;WD)
Please.... Why idHTTP runs ok and this not? With idHTTP I can't send to server long params... (SQL commands)
Last edited by Sapiem (2018-08-07 02:35:17)
Offline
IdHttp is using raw sockets, whereas THttpApiServer uses the http.sys high-performance server included in latest Windows.
For http.sys registration to work, you need to execute the program with administrator rights (root).
Once it is registered, no need to be admin any more.
Offline
Please, could you try my above code I tell me if it works for you? I did all that all of you said, and nothing.
Offline
Do you have IIS installed? Just create a site in IIS control panel for some static folder. Verify it is work. Then shut down site in IIS and use the same URI for mormot without call to addUrlAuthorise.
Offline
Do you have IIS installed? Just create a site in IIS control panel for some static folder. Verify it is work. Then shut down site in IIS and use the same URI for mormot without call to addUrlAuthorise.
I installed IIS. It works locally, but not with other PC, Smart TV, smartphone, etc.
Xampp works great...
Offline
So, problem not in mormot. Try to ask on IIS or Windows forum
But IIS only works with port 80. mORMot works too with port 80 only, but no bidirectionally, only works reading from PC where IIS is configured (and turned off, of course).
I will ask in other forums. Thanks.
Offline