Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for Power BI to Get Going #638

Closed
saviourofdp opened this issue Feb 12, 2021 · 2 comments
Closed

Wait for Power BI to Get Going #638

saviourofdp opened this issue Feb 12, 2021 · 2 comments

Comments

@saviourofdp
Copy link

saviourofdp commented Feb 12, 2021

currently I think the PBI support checks for the existence of the msmdsrv process before throwing if it can't find it.

https://github.com/Seddryck/NBi/blob/620544d23c0f52eb606c0c6dfcd67548fce538df/NBi.Core/PowerBiDesktop/PowerBiDesktopConnectionStringBuilder.cs

protected virtual string BuildLocalConnectionString(string name)
  {
      var processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
      if (processes==null || processes.Count()==0)
      {
          throw new ConnectionException
                  (
                      new InvalidOperationException("No process found with the name 'msmdsrv'. Are you sure your Power BI desktop solution is running?")
                      , string.Format("PBIX = {0}", name)
                  );
      }

 // ...
 }

If NBi is configured to start the PBIDesktop.exe in <setup />, the current version takes a while to get going which means this is very likely to fail. Would it be possible to poll until the process is up, only failing after a timeout? Something like this perhaps:

private static async Task DelayUntilServerIsRunningAsync(int delay = 2000, int timeout = 10000)
{
   var end = DateTime.Now.AddMilliseconds(timeout);
    var processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
    while (!processes.Any() && DateTime.Now < end)
    {
        await Task.Delay(delay);
        processes = System.Diagnostics.Process.GetProcessesByName("msmdsrv");
    }
    if(!processes.Any()) {
         throw new ConnectionException
                  (
                      new InvalidOperationException("No process found with the name 'msmdsrv'. Are you sure your Power BI desktop solution is running?")
                 );
    }
}

Also I have noticed that Power BI accepts a /diagnosticsPort command line parameter which allows you to specify the port of the AS server.

@Seddryck
Copy link
Owner

Thanks for the feedback and the contribution. Sounds great, will add that to the next release.

@Seddryck
Copy link
Owner

Code added and bug fix available in 1.23.0-beta0167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants