Hello there,
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 v.report({}) 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):
- Catch and handle the authentication error. Set window.visualize = null.
- Fetch the visualize.js script from your JasperReports Server again.
- 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.