Reputation: 137
I'm working on an ASP.NET MVC application that is using PowerBI Embedded to display some reports. I started with the application from the tutorial and have not made any changes to the code rendering the report. I did, however, update all the nuget packages to the latest versions.
In general, the app works fine and reports are being rendered correctly. However, sometimes I run into a problem where all the reports stop loading and I only get a flashing Power BI logo.
If I open a new browser session in incognito mode and log in on the same user it all works fine again. However, in the original tab it doesn't work until I close everything or reset the cache.
I noticed that it always happens after I am logged in for a longer period of time (30-60 minutes maybe). My best guess was that there's something wrong with the tokens, but I am not able to track it down.
Any hints what might be causing it?
UPDATE: I just noticed that after longer period of time the logo stops flashing and I get an error "This content isn't available". When I look into the browser console I get this:
wabi-west-europe-b-primary-redirect.analysis.windows.net/explore/reports/fcbf92f1-f8d7-4c61-aeb3-06f195835413/modelsAndExploration?preferReadOnlySession=true:1 Failed to load resource: net::ERR_SPDY_PROTOCOL_ERROR
reportEmbed.min.js:1 ERROR Error: Uncaught (in promise): Object: {"message":"LoadReportFailed","detailedMessage":"Get report failed","level":6,"technicalDetails":{"requestId":"6d99f480-0f1c-47d0-9598-cab569018dd0"}}
at A (reportEmbed.min.js:1)
at A (reportEmbed.min.js:1)
at reportEmbed.min.js:1
at e.invokeTask (reportEmbed.min.js:1)
at Object.onInvokeTask (reportEmbed.min.js:1)
at e.invokeTask (reportEmbed.min.js:1)
at t.runTask (reportEmbed.min.js:1)
at g (reportEmbed.min.js:1)
at t.invokeTask (reportEmbed.min.js:1)
at i.useG.invoke (reportEmbed.min.js:1)
Ye @ reportEmbed.min.js:1
Upvotes: 1
Views: 2659
Reputation: 137
The problem was, as EttoreP correctly pointed, casued by an expired token. However, the main culprit was caching. My App is not a Single Page Application, so the token should be acquired with every page load. It appeared that the results were cached for longer than the expiration time of the token. After running the page again after an hour it was using the cached token and causing errors. Adding an OutputCache attribute to the controller solved the problem. Thanks for the help and good hints!
[OutputCache(NoStore = true, Duration = 0)]
Upvotes: 2
Reputation: 414
This happens because the embedToken you use for retrive the dashboard from the powerBi rest api expires after approx 1 hour.
You have to refresh the token with a new one before the token expires, and this is not automatically handled from the Microsoft api (as far as i know).
You have to use the authentication token previously obtained and requets a new embedToken.
Consider that also the authentication token expires after some time, if this happens you have to obtain a new one before the request of the new embed token.
You can do this re-logging with user/pass or, a better solution, using the refresh token that the api gives you when you authenticate (when autenticated you retrive an auth token and a refresh token you can use for request a fresh auth token without logging again with user-pass).
Some azure documentation here about the authentication for use an azure resource.
Update:
Consider also that in the object embedToken you obtain there is the expiration date you can use for refresh the token before it expires, here some docs from azure
Upvotes: 2
Reputation: 1
This happens because your of your implementation, a good ETL can be resolve your problem, but check your connection and the cache timeout implementation.
Upvotes: -1