You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by "frankpuppa (via GitHub)" <gi...@apache.org> on 2025/09/03 08:39:16 UTC

[PR] add changes to release resources when the channel becomes inactive

frankpuppa opened a new pull request, #2241:
URL: https://github.com/apache/plc4x/pull/2241

   While I was looking into this issue I found out that there are two leaks. The first is related to the RequestTransactionManager and the other is from the NettyHashTimerTimeoutManager. As I was mentioning in the issue I opened last week, this leaks happens when the PLC goes offline and back online and the client tries to reconnecting to it in a cycle.
   
   I was only able to test this on the modbus simulator which seems to work ok with the changes I made on this branch. 
   Please provide me a feedback or any consideration. I am attaching also a small video which shows that the resources are freed as expected.
   
   [Issue link](https://github.com/apache/plc4x/issues/2229)
   
   https://github.com/user-attachments/assets/52d07125-cd87-47d7-9b96-e33f488a3039
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on code in PR #2241:
URL: https://github.com/apache/plc4x/pull/2241#discussion_r2318382862


##########
plc4j/spi/src/main/java/org/apache/plc4x/java/spi/Plc4xNettyWrapper.java:
##########
@@ -136,10 +136,19 @@ public ExpectRequestContext<T> expectRequest(Class<T> clazz, Duration timeout) {
 
     @Override
     public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+        logger.info("close.. context: {}", ctx.name());
         super.close(ctx, promise);
         timeoutManager.stop();
     }
 
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+        logger.info("channelInactive.. context: {}", ctx.name());

Review Comment:
   Please set this to "debug" or "trace"



##########
plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnectionTest.java:
##########
@@ -210,6 +213,13 @@ private void awaitIn(GateKeeper signal) {
                 throw new RuntimeException(e);
             }
         }
-    }
 
+        @Override
+        public void channelInactive(ConversationContext<Message> context) {
+            logger.info("On ChannelInactive");

Review Comment:
   Please set this to "debug" or "trace"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "frankpuppa (via GitHub)" <gi...@apache.org>.
frankpuppa commented on PR #2241:
URL: https://github.com/apache/plc4x/pull/2241#issuecomment-3248602642

   > Hi Frank, do I understand things correctly? The main difference is that you're overriding channelInactive in Plc4xNettyWrapper and forwarding that to the individual implementations? Definitely looks sensible.
   > 
   > Chris
   
   Hello Chris,
   Yes exactly, basically when the plc goes offline a channelInactive event is propagated. Within the nettywrapper I basically propagate the event in the implementations which can eventually shutdown the RequestTransactionManager and release the resources. I was able to test the functionality only for the ModbusTcpProtocol. I will fix the verbosity asap.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on PR #2241:
URL: https://github.com/apache/plc4x/pull/2241#issuecomment-3248466930

   Could you please increase the log level for your additional log output to something "debug" or "trace"? "info" makes the drivers quite noisy.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on PR #2241:
URL: https://github.com/apache/plc4x/pull/2241#issuecomment-3248460922

   Hi Frank,
   do I understand things correctly? The main difference is that you're overriding channelInactive in Plc4xNettyWrapper and forwarding that to the individual implementations?
   Definitely looks sensible.
   
   Chris


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
sruehl closed pull request #2241: add changes to release resources when the channel becomes inactive
URL: https://github.com/apache/plc4x/pull/2241


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add changes to release resources when the channel becomes inactive

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on PR #2241:
URL: https://github.com/apache/plc4x/pull/2241#issuecomment-4919045167

   Hmmm ...  with the recent rewrite of all drivers and the SPI this PR now seems quite out of date ... is this still an issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org