Announcement

Collapse
No announcement yet.

Having to restart HS4 each time before starting VS19 debug mode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Having to restart HS4 each time before starting VS19 debug mode

    HS4 is holding something open/connected, and thus wont Initialize my plugin when i start it via debug mode in VS19.

    what process do i need to kill so i dont have to restart HS4 each time?

    or better yet, can HS4 do a better job in terminating the plugin connection when i stop debug mode.
    Mark

    HS3 Pro 4.2.19.5
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
    Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

    #2
    Originally posted by mnsandler View Post
    HS4 is holding something open/connected, and thus wont Initialize my plugin when i start it via debug mode in VS19.

    what process do i need to kill so i dont have to restart HS4 each time?

    or better yet, can HS4 do a better job in terminating the plugin connection when i stop debug mode.
    I have exactly the same problem. About a year ago, some devs had an active conversation with the HS team, back then it *appeared* to have something to do with whether a web-page was consulted or not, might have been a red-herring but some fix went into some earlier release. However, for me the problem never went away and since version .6 or .7 or so, I have exactly the same issue and now all the time. I can understand that maybe us using VS19 might not represent real-life and the HS team is really focusing on getting baseline under control, but this is anoying like heck!!! I asked rjh whether there was something we could try to trace/debug but no ideas surfaced.

    I am concerned that this is not just a VS19 issue, if the PI can't be stopped properly and overwritten, this would mean that many upgrades will fail.

    Dirk

    Comment


      #3
      Dirk, thanks for the confirmation. I will bug Rich about this. I have noticed that if the plugin throws an exception during hs the Initialize call, this seems to add to the issue.

      I'm having enough frustration with repaving my plugin for hs4 that i don't need this additional headache.
      Mark

      HS3 Pro 4.2.19.5
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
      Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

      Comment


        #4
        Dirk,
        i think you are right...my code was throwing an exception while creating a Settings page. then hs4 wouldn't initialize the next time
        Mark

        HS3 Pro 4.2.19.5
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
        Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

        Comment


          #5
          I use VS19 and have no problems with starting and stopping my plugin. The only times I see HS hang is if there is an unhandled error and then I need to do a reset on HS4.
          Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
          X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
          Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
          Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
          Scripts =
          Various

          Comment


            #6
            Originally posted by mnsandler View Post
            Dirk, thanks for the confirmation. I will bug Rich about this. I have noticed that if the plugin throws an exception during hs the Initialize call, this seems to add to the issue.

            I'm having enough frustration with repaving my plugin for hs4 that i don't need this additional headache.
            I used a tool, many years ago that showed all files, thread etc and their state under Windows, believe it was a Windows tool you could download. It might be on one of my development machines, suspect 2 generations back, with Win7 still on it. Recall, I dug up some file handle that was kept open by HS3, may need to dig up the tool and do same for HS4 so we can figure out, why stopping the PI properly (that's what I always do) doesn't seem to release a hold on the .exe file so VS19 can't compile any changes, failing to write the new .exe in target HS directory until you stop HS4. Rich's view has been that it is something I'm not doing right when terminating the PI and he most likely will be right, but I have no idea where to look. So in Rich's defense, I've had similar issues over the years and they always ended up something my PI wouldn't release properly. However, we're not the only 2 complaining about this in HS4.

            Comment


              #7
              When you have any exception in sub Initialize, you'll have to restart HS4. Since it is best practice to do as little as possible in Initialize anyway, the only thing I do in the Initialize sub, is start a new thread... and return! No problem ever since.

              Code:
              Protected Overrides Sub Initialize()
                  Dim InitThread = New Thread(AddressOf Initialize2) With {.IsBackground = True}
                  InitThread.Start()
                  Status = PluginStatus.Ok()
              End Sub
              stefxx

              Comment


                #8
                Ah, I found the tool again, PROCMON (https://docs.microsoft.com/en-us/sys...nloads/procmon)
                Downloading and installing as I write this, see if that teaches me anything

                Comment


                  #9
                  Originally posted by stefxx View Post
                  When you have any exception in sub Initialize, you'll have to restart HS4. Since it is best practice to do as little as possible in Initialize anyway, the only thing I do in the Initialize sub, is start a new thread... and return! No problem ever since.

                  Code:
                  Protected Overrides Sub Initialize()
                  Dim InitThread = New Thread(AddressOf Initialize2) With {.IsBackground = True}
                  InitThread.Start()
                  Status = PluginStatus.Ok()
                  End Sub
                  Or put TRY/Exception construct around your code

                  Comment


                    #10
                    Originally posted by stefxx View Post
                    When you have any exception in sub Initialize, you'll have to restart HS4. Since it is best practice to do as little as possible in Initialize anyway, the only thing I do in the Initialize sub, is start a new thread... and return! No problem ever since.

                    Code:
                    Protected Overrides Sub Initialize()
                    Dim InitThread = New Thread(AddressOf Initialize2) With {.IsBackground = True}
                    InitThread.Start()
                    Status = PluginStatus.Ok()
                    End Sub
                    with this approach, is there anyway to report back to HS4 that the plugin didnt initialize successfully?
                    Mark

                    HS3 Pro 4.2.19.5
                    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
                    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
                    Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

                    Comment


                      #11
                      (near) real-time updates:
                      Installed procmon, first 2 attemps to stop PI and see if exe was held actually didn't reproduce the issue.
                      First attempt, I didn't do anything except let the PI initialize itself, then stop it, then do recompile, that worked.
                      Second attempt, I let the PI come up, opened up one of my feature screens, stopped PI, do recompile, still OK.
                      Third attempt, I pulled up my settings page, clicked through the tabs, stopped PI but now the .exe couldn't be overwritten.

                      Could be red-herring but many months ago, there was a suspicion that accessing weblinks had something to do with it, so perhaps something others can play with.
                      Now going to analyze the procmon log to see if that tells me anything

                      Comment


                        #12
                        There is a known issue where if the PluginFunction of your plugin is called from a script or from a feature page, then even if you shutdown the plugin properly, you can't delete or overwrite the exe file and windows says "the file is open in HS4". So far Rich wasn't able to figure out what in HS4 is holding a reference to the plugin exe.
                        The only workaround I found is to restart HS4 which can be a pain.

                        That being said, personally, while developing, it doesn't bother me much because most of the time when I debug from VS2019, I don't copy the exe to the HS4 dir but I run it remotely from the build dir instead.

                        Comment


                          #13
                          Originally posted by mnsandler View Post

                          with this approach, is there anyway to report back to HS4 that the plugin didnt initialize successfully?
                          Sure. Just set the status in the new thread (or anywhere else):

                          Code:
                          Status = PluginStatus.Fatal("Fatal error!")
                          stefxx

                          Comment


                            #14

                            if the PluginFunction of your plugin is called from a script
                            Does the HS4 API now have a means via scripting to get access to a Plugin's public methods? Github Issue #79 still shows it to be under investigation.

                            Comment


                              #15
                              Originally posted by spud View Post
                              There is a known issue where if the PluginFunction of your plugin is called from a script or from a feature page, then even if you shutdown the plugin properly, you can't delete or overwrite the exe file and windows says "the file is open in HS4". So far Rich wasn't able to figure out what in HS4 is holding a reference to the plugin exe.
                              The only workaround I found is to restart HS4 which can be a pain.

                              That being said, personally, while developing, it doesn't bother me much because most of the time when I debug from VS2019, I don't copy the exe to the HS4 dir but I run it remotely from the build dir instead.
                              Ah, probably something we discussed with you. Ran Procmon and I can confirm that once scriban is loaded and used, the PI executable becomes locked, see below.
                              Now need to start googling scribban issues

                              Click image for larger version

Name:	procmon1.png
Views:	199
Size:	525.3 KB
ID:	1398217

                              Comment

                              Working...
                              X