Announcement

Collapse
No announcement yet.

Z-Net not reconnecting after disconnect - Solved!

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

    #46
    Rich,

    Just a few observations:

    1. The light on the Z-Net remains "Green" for a long time even though the Ethernet cable is disconnected.

    2. The the plugin does seem to get buffered data that was not processed during the disconnect even though it does not establish a complete connection due to the failure of the HomeID.

    3. I have a newer Z-Net in the 911 Center office that controls our thermostat and is connected to the system through a 5 port switch. This Z-Net, like yours, does not fail like the others. It re-establishes communications quickly. My field units (6 of them) and my home system Z-Net will not do this. My home Z-Net is probably serial # 0001.

    4. I have edited the sysctl.conf file in all of the Z-Nets to change the TCP Timeout to 20 seconds.

    Bob

    Comment


      #47
      I was looking at this issue over the weekend and I found a fix that seems to work well, and does not require rebooting the Z-NET. What I am seeing is that when the Ethernet cable is pulled, the ser2net TCP connection on port 2001 persists, remaining even after the cable is reattached. After reattach, the zwave plugin tries & tries to reestablish connection, but to no avail (netstat on the Z-NET shows all the new tries queue up with state TIME_WAIT, while the old one still shows ESTABLISHED). When the original connection finally drops, all these queued tries go thru and the ensuing responses seem to confuse the plugin to various degrees (once it locked up so bad that HS thought it was a remote plugin!)

      The fix I implemented is to create an ifplugd down action that scans the netstat output for connections on port 2001 on the interface that is going down. If any of these are detected, it sends a command to the ser2net control port to disconnect that port.

      Now when I unplug the cable, the Z-NET LED reliably goes red about 10 seconds after (10 sec being the ifplugd -d value from /etc/default/ifplugd). Then when plugged back in goes green almost immediately.

      The patch consists of:
      1) a modification to /etc/rc.local, to enable the ser2net control port;
      2) a new file in /etc/ifplugd/action.d to detect a lingering connection on interface down;
      3) a script to issue the disconnect command to the ser2net control port via telnet.

      I will try to post the patch later today after I get home.

      Comment


        #48
        I will try to post the patch later today after I get home.
        That sounds logical and is much cleaner/faster than a reboot. Maybe Rich can implement something in the plugin or Z-Net to release port 2001 cleanly. Thanks for your work. That is why this forum is such a valuable tool.

        Bob

        Comment


          #49
          Originally posted by Bob_Linux_User View Post
          Thanks for your work. That is why this forum is such a valuable tool.

          Bob
          +1 from Me... better than a reboot. Thanks Zwolfpack
          Blair

          HomeSeer: HS3 Pro | Blue-Iris 4 on Windows10Pro
          | Devices: 832 | Events: 211 |
          Plug-Ins: Z-Wave | RFXCOM | UltraRachio3 | Sonos
          BLLAN | BLLOCK | NetCAM | Global Cache Pro | Blue-Iris4

          Comment


            #50
            Patch available for testing

            Originally posted by zwolfpack View Post
            The fix I implemented is to create an ifplugd down action that scans the netstat output for connections on port 2001 on the interface that is going down. If any of these are detected, it sends a command to the ser2net control port to disconnect that port.

            Now when I unplug the cable, the Z-NET LED reliably goes red about 10 seconds after (10 sec being the ifplugd -d value from /etc/default/ifplugd). Then when plugged back in goes green almost immediately.

            The patch consists of:
            1) an install script to dynamically edit the /etc/rc.local or /etc/init.d/ser2net, as required
            2) a new file in /etc/ifplugd/action.d to detect a lingering connection on interface down;
            3) a script to issue the disconnect command to the ser2net control port via telnet.
            Attached zip file contains a TAR file to upload to the Z-NET, since it doesn't have ZIP. All the files in the TAR file are also included in the ZIP file so you can easily inspect them.

            From the included 00README.txt:
            Code:
            znetdown patch
            August 2016 (dgo)
            
            CONTENTS:
            
            0. 00README.txt - this file
            1. znetdown - shell script that implements an ifplugd action.
            2. ser2net_disconnect.py - python script called by znetdown to issue a
                                       disconnect command to the ser2net daemon
            3. znetv2_ifplugd_install.sh - shell script that installs the ifplugd service,
                                       as the v2 Z-NET does not come with this installed.
            4. install.sh - shell script that installs the patch
            5. uninstall.sh - shell script that uninstalls the patch
            
            USAGE:
            
            To install the patch,
            sftp znetdown_patch.tgz to /tmp on Z-NET
            ssh to Z-NET then
            $ mkdir znetdown
            $ cd znetdown
            $ tar xzf /tmp/znetdown_patch.tgz
            $ sudo ./install.sh
            
            then reboot.
            
            To uninstall,
            $ sudo ./uninstall.sh
            
            Running install.sh & uninstall.sh as non-root user will instead display
            the commands that will run when you have root access:
            
            $ ./install.sh
            install.sh: root access required to install this patch
            install.sh: displaying commands that would be run
            cp -p /etc/rc.local /etc/rc.local-orig
            cp -p znetdown /etc/ifplugd/action.d/znetdown
            chown root:root /etc/ifplugd/action.d/znetdown
            chmod +x /etc/ifplugd/action.d/znetdown
            cp -p ser2net_disconnect.py /usr/local/HomeSeer/ser2net_disconnect.py
            chown root:root /usr/local/HomeSeer/ser2net_disconnect.py
            chmod +x /usr/local/HomeSeer/ser2net_disconnect.py
            cp -p rc.local /etc/rc.local
            chown root:root /etc/rc.local
            chmod +x /etc/rc.local
            
            $ ./uninstall.sh
            uninstall.sh: root access required to uninstall this patch
            uninstall.sh: displaying commands that would be run
            rm -f /etc/ifplugd/action.d/znetdown
            rm -f /usr/local/HomeSeer/ser2net_disconnect.py
            mv -f /etc/rc.local-orig /etc/rc.local
            
            
            ==============================================================
            If you have a Z-NETv2, install the ifplugd service as follows.
            ** !! THIS STEP REQUIRES INTERNET (WWW) CONNECTION    !! **
            ** !! IF CONNECTION NOT DETECTED, INSTALLER WILL EXIT !! **
            
            $ sudo ./znetv2_ifplugd_install.sh
            
            then reboot.
            
            If ifplugd is already installed, the script will exit.
            
            
            To uninstall ifplugd,
            
            $ sudo apt-get purge ifplugd
            Look it over and if it's within your comfort zone, give it a try. Report back on how it goes!

            r5 of the patch adds znetv2 compatibility. As noted, an additional step is necessary for the v2 since it doesn't come with the necessary service installed.
            Attached Files
            Last edited by zwolfpack; September 4, 2016, 03:49 PM. Reason: Updated to r6 for znetv2 1.0.21 compatibility

            Comment


              #51
              Thanks zwolfpack for your effort. I will give the patch a go today and let you know how it works for me. I have looked all of the files over and it looks simple enough.

              Bob

              Comment


                #52
                This sounds great. I'm having same problem too and would like to apply the patch. However, I don't know the login to the Z-Net. Tried this login. uname: homeseer pwd: hsthsths3 Doesn't work.

                Comment


                  #53
                  This sounds great. I'm having same problem too and would like to apply the patch. However, I don't know the login to the Z-Net. Tried this login. uname: homeseer pwd: hsthsths3 Doesn't work.
                  I cannot give you the password as I was sworn to secrecy by HS, but if you look at the below thread, I think you will find the answer. I have installed the patch on all seven of my Z-Nets and it seems to work great. If you are not familiar with linux be careful not to brick your Z-Net. I am sure Rich will devise an update for the Z-Net.

                  http://board.homeseer.com/showthread.php?t=183021

                  Bob

                  Comment


                    #54
                    I don't believe the issue is related to the keep-alive, so I removed that post.

                    I made a change that will detect if the key process in the z-net goes down and automatically restart it. I am guessing that this process is stopping when you cannot connect.

                    Connect to your Z-NET from find.homeseer.com and update it by clicking the "Update" button. When the update completes, you will need to reboot the unit. You can reboot by clicking on the "Submit" button (even if you did not make a change), this will cause the unit to restart.

                    Let me know if this helps with the issue.

                    Note that I only posted an update to the original Z-NET. If you have a newer unit, the Update button will not be there. I will post that update once I get some feedback.
                    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                    Comment


                      #55
                      Interesting, I will take a look at this. It should also handle a case where the wifi goes down as some users use wifi. I will see if I can bake this into the process.

                      Originally posted by zwolfpack View Post
                      I was looking at this issue over the weekend and I found a fix that seems to work well, and does not require rebooting the Z-NET. What I am seeing is that when the Ethernet cable is pulled, the ser2net TCP connection on port 2001 persists, remaining even after the cable is reattached. After reattach, the zwave plugin tries & tries to reestablish connection, but to no avail (netstat on the Z-NET shows all the new tries queue up with state TIME_WAIT, while the old one still shows ESTABLISHED). When the original connection finally drops, all these queued tries go thru and the ensuing responses seem to confuse the plugin to various degrees (once it locked up so bad that HS thought it was a remote plugin!)

                      The fix I implemented is to create an ifplugd down action that scans the netstat output for connections on port 2001 on the interface that is going down. If any of these are detected, it sends a command to the ser2net control port to disconnect that port.

                      Now when I unplug the cable, the Z-NET LED reliably goes red about 10 seconds after (10 sec being the ifplugd -d value from /etc/default/ifplugd). Then when plugged back in goes green almost immediately.

                      The patch consists of:
                      1) a modification to /etc/rc.local, to enable the ser2net control port;
                      2) a new file in /etc/ifplugd/action.d to detect a lingering connection on interface down;
                      3) a script to issue the disconnect command to the ser2net control port via telnet.

                      I will try to post the patch later today after I get home.
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #56
                        Rich,

                        I do not know if you read the post by zwolfpak and the patch to release the port on the Z-Net but this patch work like a dream and does not require a reboot of the Z-Net. The Z-Net quickly realizes that the connection is lost to the host and releases port 2001. The plugin picks up a new connection immediately.

                        Bob

                        Edit: Rich and I were typing at the same time --- Sorry

                        Comment


                          #57
                          I made a change that should handle more cases than just an Ethernet cable being pulled. For example, the network could go down at another point and the box would still have a good Ethernet connection, or you might be using WIFI.

                          I enabled a timeout on the network connection. HS sends a NULL command to the Z-NET once every 10 seconds, to check the connection. I enabled a 20 second timeout in the Z-NET. If the Z-NET does not receive any data after 20 seconds, it resets the port. You can see this happening as the the LED will now go RED. The 20 seconds might be a bit aggressive, but update your Z-NET to build 1.0.19 and give it a try.
                          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                          Comment


                            #58
                            I made a change that should handle more cases than just an Ethernet cable being pulled. For example, the network could go down at another point and the box would still have a good Ethernet connection, or you might be using WIFI.

                            I enabled a timeout on the network connection. HS sends a NULL command to the Z-NET once every 10 seconds, to check the connection. I enabled a 20 second timeout in the Z-NET. If the Z-NET does not receive any data after 20 seconds, it resets the port. You can see this happening as the the LED will now go RED. The 20 seconds might be a bit aggressive, but update your Z-NET to build 1.0.19 and give it a try.
                            I will do some testing with this. I will back out the patch before testing.

                            Bob

                            Comment


                              #59
                              Originally posted by rjh View Post
                              I made a change that should handle more cases than just an Ethernet cable being pulled. For example, the network could go down at another point and the box would still have a good Ethernet connection, or you might be using WIFI.

                              I enabled a timeout on the network connection. HS sends a NULL command to the Z-NET once every 10 seconds, to check the connection. I enabled a 20 second timeout in the Z-NET. If the Z-NET does not receive any data after 20 seconds, it resets the port. You can see this happening as the the LED will now go RED. The 20 seconds might be a bit aggressive, but update your Z-NET to build 1.0.19 and give it a try.
                              One of my Z-Nets is a "Z-NET V2 Configuration - Version 1.0.17 " which a) does not offer the 1.0.19 update and b) does not utilize any of the prior passwords.

                              The patch posted by zwolfpack corrected the problems in my 2 older Z-Nets. I will back out the patch and do the update to 1.0.19 on them.

                              What do I do with my v2 Z-Net?
                              HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                              Comment


                                #60
                                Rich,

                                I have tested the .19 update and it seems to function well. Time will tell if the 20 seconds is too aggressive and causes false disconnects. I will continue to monitor. I also have some V2 Z-Nets that do not offer an "Update" option but I was able to put in the patch from zwolfpack.

                                Bob

                                Comment

                                Working...
                                X