Authentication error / Refresh credentials? Visualize.JS

Hello there,

We are currently using Visualize.JS to display charts and tabular data inside our application. At the moment, we are using plan basic authentication for testing purposes.
Sometimes, after using it a while or leaving the computer on and coming back... we get this message in the console:
[Error] Failed to load resource: the server responded with a status of 401 (Unauthorized) (reportExecutions, line 0)
[Error] 11:28:16.38 [bi/component/Report] [ERROR] - authentication.error : Authentication error
When this happens we do not get any output. Is there any way to detect this and authenticate "again"? Because when I try to do so it does not work. It looks like the only way possible to make it authenticate again is to clean the browser cache.
Any ideas?
Thanks in advance.
agustin_2's picture
Joined: Sep 10 2014 - 11:18am
Last seen: 7 years 10 months ago

1 Answer:

In case you're still looking for an idea on this...

We were experiencing a similar issue in which these 401 statuses would be returned after a period of inactivity in our application (we're embedding reports using Visualize.js). Attempting to run any reports, even with the authentication username / password included every time, continued to return 401. A page refresh fixed the issue, however. We were able to catch and attempt to handle this with the error handler attached to the{}) function.

It appears that some of the session information is actually stored within the visualize.js script that you pull from the server before executing any reports. We found the following steps fix this issue (and can be done behind the scenes without refreshing the page or alerting the user):

  1. Catch and handle the authentication error. Set window.visualize = null.
  2. Fetch the visualize.js script from your JasperReports Server again.
  3. Execute the report again.

These steps have effectively resolved our issue, though I suspect that there may be a more proper solution out there if anyone has better knowledge of the visualize.js source code and knows how this session information is stored.

briann's picture
Joined: Jan 22 2015 - 9:06am
Last seen: 7 years 8 months ago