MilestoneSystemsInc / PowerShellSamples

A collection of samples for managing your Milestone XProtect VMS using MilestonePSTools in PowerShell
https://www.milestonepstools.com
MIT License
36 stars 12 forks source link

Exception calling "GetVideoDeviceStatistics" with "2" argument(s): "Unable to connect to the remote server" #118

Closed codypaternostro closed 7 months ago

codypaternostro commented 8 months ago

Exception calling "GetVideoDeviceStatistics" with "2" argument(s): "Unable to connect to the remote server"
At line:4 char:1
+ $service.GetVideoDeviceStatistics((Get-VmsToken), $cameraIds)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

It is not so much an issue but rather a posting to help others who encounter an issue related to using commands associated with Get-RecorderStatusService2. This means your recording server is not allowing inbound connections using port 7563: https://doc.milestonesys.com/latest/en-US/les2vp/calp_ts_ports_required.htm

Port 7563 is required for inbound connections. You can add a rule to your server using Windows Firewall or via PowerShell.

New-NetFirewallRule -DisplayName "Allow Inbound TCP 7563" -Direction Inbound -Protocol TCP -LocalPort 7563 -Action Allow

You can test this by seeing if streams are available remotely using the smart client. No video means 7563 is being filtered. Alternatively, you can use: https://www.milestonepstools.com/commands/en-US/Get-RecorderStatusService2/#example-1

Connect-ManagementServer -ShowDialog -AcceptEula
$recorder = Get-VmsRecordingServer | Out-GridView -OutputMode Single
$service = $recorder | Get-RecorderStatusService2
$cameraIds = ($recorder | Get-VmsHardware | Get-VmsCamera).Id
$service.GetVideoDeviceStatistics((Get-VmsToken), $cameraIds)

This is a great test to understand what is being called and why. Hope this helps someone!

joshooaj commented 7 months ago

Thanks again for sharing the issue and resolution @codypaternostro! I'm sure it'll end up helping others in the future 🍻