Demo "music" does not work for me

Hi

The TMS XData demo "music" does not work after installation. The server starts without any problems.
The client starts but I get an error that the "config/config.json" is not found. I have copied the "config" folder to several locations but still, the client cannot find it. What is the correct location for "config" folder? It did not exist under the "music" folder.

I can see the login page on the client. But after the typing the password I get another error. On the server side I can see the followings:

                  Welcome to XDataMusicServer demo                 
                                                                   
The source code is given as is. The author is not responsible     
for any possible damage done due to the use of this code.         

Config file found.
[2019-01-03 01:49:21.447] [INFO] Auth server module listening at "http://+:2001/tms/xdata/music/auth"
[2019-01-03 01:50:12.512] [INFO] Api server module listening at "http://+:2001/tms/xdata/music/api"
[2019-01-03 01:50:12.512] [INFO] Servers started. Press ENTER to stop.
[2019-01-03 01:50:26.772] [INFO] GET /tms/xdata/music/auth/$model HTTP/1.1
[2019-01-03 01:50:36.453] [INFO] OPTIONS /tms/xdata/music/auth/LoginService/Login HTTP/1.1
[2019-01-03 01:50:36.457] [INFO] POST /tms/xdata/music/auth/LoginService/Login HTTP/1.1
[2019-01-03 01:50:45.904] [INFO] OPTIONS /tms/xdata/music/api/$model HTTP/1.1
[2019-01-03 01:50:45.908] [INFO] GET /tms/xdata/music/api/$model HTTP/1.1
[2019-01-03 01:50:45.910] [INFO] 401 Unauthorized on GET /tms/xdata/music/api/$model HTTP/1.1

What can I do to make it work?

Thanks
emwamin

The client error saying config file was not found is ok, and is the default behavior. You should not be required to change anything in the demo to make it work. Can you please revert back to the original source code, removing config files you have created/moved, etc.?

Then let me know exactly what doesn't work. As I said, the 404 error about the config.json file is expected and harmless.

Hi

Ok. Lets ignore error 404 on the browser about the config file.

I just uninstalled XData and installed the release Dec 18 2018. I did remove the old Demo folder to make sure that I am running a fresh and unchanged demo.

The problem still exists. On the browser I see the following:

the link on the browser is: localhost:8000/XDataMusicWeb/index.html

and then:

Oops... an error occurred!

Message

Reload web application


On the server side I get the error:

[2019-01-11 13:21:43.807] [INFO] 401 Unauthorized on GET /tms/xdata/music/api/$model HTTP/1.1

Please advise.

BR
emwamin

Can you please try the following: change unit Auth.Service.Login.pas in project XDataMusicServer.

Changing this line (around line 46):


    Jwt.Claims.Expiration := IncHour(Now, 1);


By this:


    Jwt.Claims.Expiration := IncHour(Now, 10);


Please let me know if this makes the demo work.

Hi 


I did that but it did not help. The code was not exactly as you wrote. I just changed 1 to 10.

Jwt.Claims.Expiration := TTimeZone.Local.ToUniversalTime(IncHour(Now, 10));

BR
emwamin


Please reload web app with console open, then when the error appears, export the request in the network tab (right-click the request, use Copy -> Copy all as HAR) and send it to me so I can inspect better what’s going on, thanks.
Also please provide the error messages that appear in console.

In the meanwhile, try using IncHour with a big value, like


IncHour(Now, 100)

Hi


I changed the value to 100 and it works now.

    Jwt.Claims.Expiration := TTimeZone.Local.ToUniversalTime(IncHour(Now, 100));

Is there any reason why it did not work just for me with the default value 1?

BR
emwamin
It's something related to time zones and UTC conversion. First of all you should remove the ToUniversalTime call. That is wrong in the demo, indeed. Please use:


Jwt.Claims.Expiration := IncHour(Now, 10);


Then you can play with the "10" value to see what works (1, 10, 24)?
Also, what is your time zone?
Finally after all the above is done, please provide the HAR file I mentioned above, that will help to inspect what exactly is going on. Thank you.

Hi

I cannot get HAR file. I cannot find the popup menu as you described. Maybe it is browser dependent.
But I can see that the "Token expired" is causing the error.

Also I sometimes get the following error under my browser. Despite the error, everything works:

ERROR
Uncaught TypeError: Cannot use 'in' operator to search for '3' in undefined | TypeError: Cannot use 'in' operator to search for '3' in undefined at Object.HandleDoMouseMove (http://localhost:8000/XDataMusicWeb/XDataMusicWeb.js:15524:42) at cb (http://localhost:8000/XDataMusicWeb/XDataMusicWeb.js:216:26)
at http://localhost:8000/XDataMusicWeb/XDataMusicWeb.js [15524:42]

Are you using Google Chrome? If you are using a different browser, you should have a similar option as well. It's just an export of all the HTTP requests performed by the application.


About the second error: are you running the app in debug mode? Does the browser present you with the call stack at the time of error, of the Pascal code (not JS)?

Hi,  

quite new to xdata (and web core). I'm trying to understand server and client code in "music" demo.
nice coding... but I'm getting "Error 401. Could not connect retrieve Xdata model from http://localhost:2001/tms/xdata/music/api/$model"  at design time when I try to get fields list for a dataset.  At runtime everything is ok.  
   
(just updated webcore to  1.2.5.0 all forms in the web/music demo don't open,  property TabOrder doesn't exists)

Saverio

The server in the demo is protected, you need to send an authentication token to access it. You can set an authentication token in TXDataWebConnection at design-time using property DesignData.Headers. That's its main purpose.

However, when in development mode which is this case, maybe the easiest thing to do is just temporarily disable the authentication requirement, by removing the JWT middleware from the XData server.

Regarding the TabOrder error property, I cannot reproduce it here. It looks everything is working fine - I even took the effort to reinstall TMS Business and TMS Web Core in a blank new machine, and the demo is working ok.

Thankyou Wagner!

tried to remove JWT from the XData server but I've some troubles... 
unit Sparkle.Comp.JwtMiddleware is automatically added at compile time and the api service doesn't start with error  "Class TSparkleJwtMiddleware not found" 

the  apiservermodule is now:

type
  TApiServerModule = class(TDataModule)
    AureliusConnection1: TAureliusConnection;
    SparkleHttpSysDispatcher1: TSparkleHttpSysDispatcher;
    XDataConnectionPool1: TXDataConnectionPool;
    XDataServer1: TXDataServer;
    XDataServer1Logging: TSparkleGenericMiddleware;
    XDataServer1CORS: TSparkleCorsMiddleware;
    XDataServer1Compress: TSparkleCompressMiddleware;
    procedure XDataServer1EntityInserting(Sender: TObject;
      Args: TEntityInsertingArgs);
    procedure XDataServer1EntityModifying(Sender: TObject;
      Args: TEntityModifyingArgs);
    procedure XDataServer1EntityDeleting(Sender: TObject;
      Args: TEntityDeletingArgs);
    procedure DataModuleCreate(Sender: TObject);
    procedure XDataServer1LoggingMiddlewareCreate(Sender: TObject;
      var Middleware: IHttpServerMiddleware);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure StartApiServer(ABaseUrl: string);
  end;

could you help? 

what's the  key for designdata.headers solution? 

and.... while waiting for your help I'll remove and reinstall WebCore... (the problem od the Taborder appeared yesterday when I upgraded to the latest version)

ciao
Saverio

....TabOrder problem update...  remove/reinstall  1.2.5.0  and 1.2.4.1 always the same problem... 

design package TMS WEB Core Design time  cannot be activated with error: 
Impossibile trovare il punto di ingresso 
@S_yste@Net@HttpClient@Win@TCertificateStore@$bcdtr$qqrv della procedura nel collegamento dinamico  .....\TMSWEBCorePkgDEDXE11.bpl 

saverio

Which Delphi version are you using? Can you please make sure you have applied all existing updates to your Delphi edition?

You remote the JWT middleware by right-clicking the TXDataServer component, choose "manage middleware list..." and then remove the JWT middleware from the list that appears.

Thankyou Wagner... and I'm sorry for some extra work... as I said I'm new (quite new because I started to try XData in march but after 1 or 2 days I have had to pause unitl yesterday).... 


Used to Delphi I was expecting  "Middleware list" in object inspector...  I found it in the popop menu for XDataServer just 20 minutes before of your suggestion...  anyway at the moment  the problem is solved but I'm wondering of how to deal with  authentication (Jwt) when  design/deploy (what strategy?)

Thankyou again... 

Saverio

Tokyo 10.2.2


this problem too has been fixed... after a ton of remove/install cycle   starting (1.1.3.0, 1.2.4.1, 1.2.5.0)
don't ask... finally it works...  but... at delphi start while loading packages it say Web Core 1.1.3.0 while the subscprition manager reports  1.2.5.0  (I guess the installed one is 1.1.3.0 because the files in bpl directory are dated  19/01/2019...) .... 

I can see a new version is available for download... (1.2.4.1, 1.2.5.0, 1.2.5.1 in 3 days...?)

Saverio

Perhaps there is still an old version TMS WEB Core BPL file around & used on your system.
Please verify via IDE menu: Component / Install Packages what BPL files are used for TMS WEB Core and when old version are still used, remove these and replace by the latest version v1.2.5.1