You are not logged in.
Hello, I made an MVC Server according to example 30.
I need to create a second server that will be a client of the first server. How do I do that?
First MVC Server - Main
Const
Root = 'first';
var aModel: TSQLModel;
aServer: TSQLRestServerDB;
aApplication: T_Application;
aHTTPServer: TSQLHttpServer;
begin
with TSQLLog.Family do
begin
Level := LOG_VERBOSE;
DestinationPath := ExeVersion.ProgramFilePath + 'log';
end;
try
//aServer.DB.LockingMode := lmExclusive;
try
aModel := CreateModel(Root);
aServer := TSQLRestServerDB.Create(aModel,ChangeFileExt(ExeVersion.ProgramFileName,'.db'),true);
aServer.DB.Synchronous := smNormal;
aServer.CreateMissingTables;
aApplication := T_Application.Create;
try
aApplication.Start(aServer);
aHTTPServer := TSQLHttpServer.Create('80', [aServer], '+',useHttpApiRegisteringURI,32,secSynShaAes);
try
aHTTPServer.RootRedirectToURI(root+'/default');
aServer.RootRedirectGet := root+'/default';
// redirect blog to blog/default
writeln('"MVC First Server" launched on port 80 using ',aHTTPServer.HttpServer.ClassName);
writeln(#10'You can check http://localhost/'+root+'/mvc-info for information');
writeln('or point to http://localhost/'+root+' to access the web app.');
writeln(#10'Press [Enter] to close the server.'#10);
readln;
finally
aHTTPServer.Free;
end;
finally
aApplication.Free;
end;
except
on E: Exception do
begin
writeln(E.Message);
readln;
end;
end;
finally
aServer.Free;
end;
How do I connect to the first server database?
Second MVC Server - client of the first
Const
Root = 'second';
var aModel: TSQLModel;
aServer: TSQLHttpClientWinHTTP;
aApplication: T_Application_ADMIN;
aHTTPServer: TSQLHttpServer;
db:TSQLRestServerRemoteDB;
ServerDefinition:TSQLHttpServerDefinition;
begin
with TSQLLog.Family do
begin
Level := LOG_VERBOSE;
DestinationPath := ExeVersion.ProgramFilePath + 'log';
end;
try
try
aModel := CreateModel('first');
//TSQLRestServerDB.Create(aModel,ChangeFileExt(ExeVersion.ProgramFileName,'.db'),true);
aServer := TSQLHttpClientWinHTTP.Create('localhost','80',aModel);
db :=TSQLRestServerRemoteDB.Create(aserver);
if not aServer.SetUser('User','Pass') then
begin
writeln(#10'too bad, invalid login'#10);
readln;
end;
aApplication := T_Application_ADMIN.Create;
try
db.Model.Root := root;
db.RootRedirectGet := root+'/default';
aApplication.Start(db);
aHTTPServer := TSQLHttpServer.Create('80', [db], '+',useHttpApiRegisteringURI,32,secSynShaAes);
try
writeln('"MVC Second Server" launched on port 80 using ',aHTTPServer.HttpServer.ClassName);
writeln(#10'You can check http://localhost/'+root+'/mvc-info for information');
writeln('or point to http://localhost/'+root+' to access the web app.');
writeln(#10'Press [Enter] to close the server.'#10);
readln;
finally
aHTTPServer.Free;
end;
finally
aApplication.Free;
end;
except
on E: Exception do
begin
writeln(E.Message);
readln;
end;
end;
finally
aServer.Free;
end;
So, when I try to run the code below:
AuthUser_Extend: = TSQLAuthUser_Extend.CreateAndFillPrepareJoined (RestModel,
'LogonName =? or AuthUser_Extend.Email =? and (AuthUser.ID = AuthUser_Extend.AuthUser) ',
[],
[LogonName, LogonName]
);
raises the "Abstract Error"
...
20171006 19074230 clnt mORMotHttpClient.TSQLHttpClientWinHTTP (025A78A0) GET bigboss? Session_signature = 50AF95DC00067775E49D36ED status = 500 len = 88 state = 0
20171006 19074230 - 00750.030
20171006 19074230 ERROR mORMotHttpClient.TSQLHttpClientWinHTTP (025A78A0) GET bigboss returned 500 (Internal Server Error) with message {"errorCode": 500, "error": {"EAbstractError": {"EAbstractError": "Abstract Error"}}} stack trace API 0056B482 005F223F 005FC7E2 005FD3A1 0061C6CC 005F6C3A 005E9454 007668A8 0063C8D7
20171006 19074230 srvr mORMot.TSQLRestServerRemoteDB (025EC0D0) POST bigboss / Sign_In SOA-Method -> 307 with outlen = 0 in 3657364 us
....
tks,
[]s
Offline
Sorry if I was not clear. I need the second MVC Server to connect to the first MVC Server database. It is possible?
tks
Last edited by Desenvolvimento (2017-10-07 01:45:31)
Offline