Uploaded image for project: 'Apache PLC4X'
  1. Apache PLC4X
  2. PLC4X-139

PLC4X leaks sockets in case of connection problems

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 0.4.0
    • 0.5.0
    • Core
    • None

    Description

      See my description on the list: https://lists.apache.org/thread.html/4aa229421668a92275e33643dbc57f2fea29cee7ffcb07891f58c9eb@%3Cdev.plc4x.apache.org%3E

      I created a MWE like that

      public static void main(String[] args) throws Exception {
              IntStream.range(0, 100).parallel().forEach(i -> createConnection(i));
          }
      
          private static void createConnection(int i) {
              System.out.println("trying " + i);
              try (PlcConnection plcConnection = new PlcDriverManager().getConnection("s7://192.168.167.211/0/0")) {
      
              } catch (Exception e) {
               logger.error("Kann keine Verbindung zu der angegebenen Adresse aufbauen");
              }
          }
      

      where the IP is not reachable, thus it fails every time.

      When looking at the open sockets with (works on my Mac)

      while true; do lsof -p 16843 | wc -l; sleep 10; done
      

      I get the output

          1640
          1640
          1640
          1736
          1736
          1736
          1832
          1832
          1832
          1928
          1928
          1928
          2024
          2024
          2024
          2120
          2120
          2120
          2216
          2216
          2216
          2312
          2312
          2312
          2408
          2408
          2408
          2504
          2504
          2504
          2500
      

      So this reall sems to be the case.

      I think this could be due to us only propagating the exception but not closing the channel, I will investigate further.

      Attachments

        Issue Links

          Activity

            People

              julian.feinauer Julian Feinauer
              julian.feinauer Julian Feinauer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m