XData server with JWT on Windows 2102 R2 server

I have an XData server with JWT that works flawlessly with the XDataclient when they both run on my machine.

For testing purposes I copied the XDataserver with the database and the client to an external Windows 2012 R2 server. First I tried to run client and server together on this machine and I keep getting this error:

Status
        code: 500 Error Code: InOutError Invalid file name - %s


I then
tried to connect with the client from my machine to the server on
the external machine over the internet: same problem.

I narrowed the problem down to the moment I first use an objectmanager. I do this:

1. plain connection from the client to the server to get a JWT. This works ok.

2. JWT arrives and is correct (the same on both sides).

3. JWT Bearer header added.


   
        ClientData.ClientConnectie.Client.HttpClient.OnSendingRequest :=

            procedure(Req: THttpRequest)

            begin

              Req.Headers.SetValue('Authorization', 'Bearer ' +
        cJWT);

            end;

4. Request information about the database from the client:

   

ClientData.ClientConnectie.InitDatabaseInfo;




5. Function in the Servicepart of the XData server:

function TMyServerService.GetDatabaseInfo:
        TList<TDatabaseInfo>;

      var

        Statement   : IDBStatement;

        DBStmt      : IDBDatasetStatement;

        OM          : TObjectManager;

        Dataset     : TDataset;

        cQuery      : string;

        DatabaseInfo: TDatabaseInfo;

      begin

        result := TList<TDatabaseInfo>.Create;

        OM     := TXDataOperationContext.Current.GetManager;

      
     


The error occurs in the last statement.
MadExcept gives this information:


exception number   : 1
exception class    : EXDataOperationRequestException
exception message  : XData server request error. Uri: http://127.0.0.1:2021/myserver/functies/GetDatabaseInfo Status code: 500 Error Code: InOutError Invalid file name - %s.

main thread ($1490):
00a6daa7 +4d7 MyClient.exe XData.Client           513 +111 TXDataClient.GetServiceInterface$ActRec.$0$Body
004e3669 +039 MyClient.exe System.Rtti          11597   +2 TVirtualInterface.RawCallback
004e332f +027 MyClient.exe System.Rtti          11564   +0 TVirtualInterface.Create[1]$ActRec.$0$Body
004e3112 +076 MyClient.exe System.Rtti          11154   +4 TMethodImplementation.Intercept
004e2c9f +00b MyClient.exe System.Rtti          10908  +24 RawIntercept
00b5e473 +023 MyClient.exe UnClientConnectieIMP   374   +4 TClientConnectie.InitDatabaseInfo


This all works fine on my local machine and requesting the JWT works fine also. I just don't know what to look for.

Hi Ronald,


This is a very tricky one. The error doesn't indicate much, from what I see from RTL, it's a very low-level error handling. The information you sent doesn't indicate with 100% accuracy that the problem is raising in the line you indicated (TObjectManager creation). The MadExcept report doesn't indicate that. How did you find it was the correct line?

Even then, if that's for sure the line where error is happening, the only reason I see for an Invalid File name error upon such TObjectManager creation is because it would try to connect to the database. Are you sure your database connection settings are valid for the server side? Are you using SQLite? If yes, are you using a valid file name for the SQLite database? 

I can't get the server to work anymore on my own machine now too.
Using the URL method doesn't give me any data either, but I think that is because of the multi-tenancy on the server.
Can you tell me what the convention is for more than one database on the server?
The manual states:
http://server:2001/tms/xdata/Customer?$top=2&$orderby=Name
but I think something has to be added to reach the right database.

I'm beginning to think this might be caused by the new version of XData, but I'm not sure yet. The server has not been altered for weeks, only recompiled with the new XData.

There is no convention for multi-tenancy, it depends on how you implement it. It's your code that tells XData how to deal with multiple databases.


Do you have the previous version of XData to rebuild and check? Are you able to reduce this to a minimum project that reproduces the problem?

It's not the version of XData, I think.
I restored everything from my backup of yesterday, restarted Windows and Delphi, recompiled the Server and Client and everything works again om my machine. Which is strange, because the code is not altered....
It still does not work on the server though. So I'm back to square one.

Have you checked the database settings as I mentioned?

Also, if you are able to reproduce the issue in your computer, you can run your server in debug mode using Debug dcu's and check the exact line number that is causing the problem and the call stack. It should give you more insight about it.