Universal Dashboard 2.9.0 Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ().'

@adam

I have been trying to do a backup database task using dbatools and i have decided to create the task as a job so i can track the progress rather than have just a spinner with no value.

the way i though about tracking the progress was thru an invoke to the sql server and query the database back progress and view the results in a grid as below image

i was getting data no problem since i was using

while($Session:Backup.State -ne 'Completed')
                        {
                        Set-UDElement -Id 'Report' -Content {

                        New-UDGrid -Id "BackupGrid" -Title "Backup Monitor" -Headers @("Session ID","Command","Percent Complete","ETA Completion Time","ETA Min","ETA Houres") -Properties @("Session_ID","Command","Percent_Complete","ETA_Completion_Time","ETA_Min","ETA_Hours") -PageSize 10 -Endpoint {
 
                       $Backup = Invoke-Command -ComputerName pc1 -ScriptBlock {
                                 Invoke-DbaQuery -SqlInstance pc1 -Query "SELECT r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete)
                                 AS [Percent_Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA_Completion_Time],
                                 CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA_Min],
                                 CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA_Hours],
                                 CONVERT(VARCHAR(1000),(SELECT SUBSTRING(text,r.statement_start_offset/2,
                                 CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END)
                                 FROM sys.dm_exec_sql_text(sql_handle))) AS [SQL]
                                 FROM sys.dm_exec_requests r WHERE command IN ('BACKUP DATABASE') " }
  
                       $BackupOut = foreach($_ in $Backup) {

                                 [PSCustomObject]@{
                                   Session_ID          = $_.session_id
                                   Command             = $_.command
                                   Percent_Complete    = $_.Percent_Complete
                                   ETA_Completion_Time = $_.ETA_Completion_Time
                                   ETA_Min             = $_.ETA_Min
                                   ETA_Hours           = $_.ETA_Hours

                                   }
                      
                                  } 
                                  
                                  $BackupOut | Out-UDGridData 

                               } -AutoRefresh -RefreshInterval 60
                            }
                         } 

The Problem: when that backup start and am seeing progress in my Grid in about 2 minutes chrome dev tools show the following error

image

The Grid will show me data but when the backup is done i no longer see the next step in the page but i can see the script continue to run and finish other steps without me seeing any progress in the page.

if i dont use the process as a job i dont see this issue like if i just initiated the command as invoke-command …etc with a spinner and a card to track each step like
Set-UDElement -Id "Card" -Content { New-UDParagraph -Text "Backing up DB please wait..." }

i have even tried to add a cpu monitor chart and keep it refresh every 5 sec to see if it will resolve the issue but no luck.

A 1006 is because the websocket connection was closed abnormally. It’s kind of a generic error. Is there anything of note in the UD log?