NullReference when lifting privacy mask

I just upgrade from MIPSDK 2021 R2 to 2022 R3. Before export we have the option to lift privacy mask. After upgrade we sometimes get a NullReferenceException inside the MIPSDK when doing this. Have I missed something in the upgrade?

System.NullReferenceException: Objektreferensen har inte angetts till en instans av ett objekt.
 
  vid VideoOS.Platform.Util.SecurityAccess.GetSecurityClient(ServerId serverIdParm)
 
  vid VideoOS.Platform.Util.SecurityAccess.HasOverallPermission(ServerId serverId, String securityNamespaceName, String securityAction)
 
  vid VideoOS.Platform.UserContext.SetPrivacyMaskLifted(Boolean liftMask)
 
  vid Tennotech.Hilding.Watchman.Player.MilestonePlayer.MilestoneExportJob..ctor(IExporter exporter, CancellationTokenSource cancellationTokenSource) i C:\BuildAgent\work\8d9805fa21849b62\Source\Players\Tennotech.Hilding.Watchman.Player.MilestonePlayer\MilestoneExportJob.cs:rad 46
 
  vid Tennotech.Hilding.Watchman.Player.MilestonePlayer.MilestoneDeviceExporter.<ExportAsync>d__4.MoveNext() i C:\BuildAgent\work\8d9805fa21849b62\Source\Players\Tennotech.Hilding.Watchman.Player.MilestonePlayer\MilestoneDeviceExporter.cs:rad 54

Hi Ola,

We have not been able to reproduce this, so a few follow-up questions:

Best regards,

Peter

Hello,

I have now been able to investigate this a little more. Here are some answers to your questions.

I cannot reproduce the problem with ExportSample. I am able to reproduce the problem with latest MIPSDK as well. I have tested with several server versions from 2019 R1 to 2022 R3 and I always get the error. I thought I managed to make an export the other day, but when I tested today all my exports end with this NullReferenceException.

I have been able to debug to find the exact line where the error occurs. It turns out LoginSettingsCache.GetLoginSettings(serverId); in SecurityAccess.GetSecurityClient returns null. The MIPSDK log is complaining about the LoginSettingsCache, but I have no problem viewing video.

2023-04-14 14:05:36.235 Debug: Environment:Initialize (): 
2023-04-14 14:06:36.880 Debug: LoginSettings.ctor (): Constructed for instance=98d74d47-c7fb-49d7-92a6-896ec2933cd8, IdentityTokenCache is null
2023-04-14 14:06:37.007 Debug: ConnectionCheck:IsOAuthServerOnline (): Error(s): No authorization server found at: https://10.255.4.15/idp/.well-known/openid-configuration: Fjärrcertfikatet är ogiltigt enligt valideringsproceduren.
2023-04-14 14:06:37.358 Debug: FindBestAddress (): Address was found: http://10.255.4.15/. Is OAuth server: True
2023-04-14 14:06:37.366 Debug: LoginSettings.ctor (): Constructed for instance=3d72515a-de50-448f-ad6b-0075f5b1a587, IdentityTokenCache is null
2023-04-14 14:06:37.369 Debug: LoginSettingsCache.Add (): Duplicate Entry on Hostname:+10.255.4.15
2023-04-14 14:06:38.244 Error: SiteInfoManager:SiteInfo (): Site already added - new add ignored
2023-04-14 14:06:38.298 Debug: SystemInfo (): Setting IdentityToken = value for instance=98d74d47-c7fb-49d7-92a6-896ec2933cd8
2023-04-14 14:06:38.358 Debug: LoginServerOauth.CreateClient (): Creating an HTTP client using uri: http://10.255.4.15/ManagementServer/ServerCommandServiceOAuth.svc
2023-04-14 14:06:39.022 Debug: ProxyClientBase (): Creating an HTTP client using uri: http://10.255.4.15/
2023-04-14 14:06:39.127 Debug: LoginServerbase (): New token posted - Server: 10.255.4.15
2023-04-14 14:06:40.048 Error: LicenseManager (): Login settings not found. EnvironmentType: Standalone
2023-04-14 14:06:40.058 Error: License Load (): Exception source:      VideoOS.Platform
Exception type:        VideoOS.Platform.MIPException
Exception message:     Login settings not found.
Exception target site: GetCompatibilityHandler
   vid VideoOS.Platform.License.LicenseManager.GetCompatibilityHandler()
   vid VideoOS.Platform.License.LicenseManager.LoadLicenseInformation()

Ok, I found the problem. Obviously I need to call Environment.Login to be able to lift privacy mask. Not exacly sure what Environment.Login is supposed to do but obviously this call was not needed in earlier versions and I am still able to view Live/Playback video without calling it. Maybe a better exception than NullReferenceException could be thrown if login is required.

Have a nice weekend.

/Ola, Tennotech

Hi Ola. Glad to hear that you solved the problem. It has always been the intention that calling Login explicitly is required, so if it was not needed in some situations in previous versions was basically a bug. We did some refactoring and cleanup of this area of the code for the latest release, so it is likely that this has brought back the intended functionality.

Best regards,

Peter

We are still able to view Live/Playback-video without Login. I think also the audio input/output is accessible without Login. At least I have not received any complaint that it is not working. Maybe it could be a good idea to check which parts need Login-protection and throw a proper access denied exception if accessed without calling Login.

Best regards,

Ola