I found a workaround by digging through the example code: End the application with an explicit System.exit(0);
https://github.com/apache/plc4x/blob/b784dedaa787e52e7907085bf096e8ea2e093f3b/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/HelloPlc4xRead.java#L93 Then it does terminate the application. Niels On Mon, Jan 2, 2023 at 12:30 PM Niels Basjes <[email protected]> wrote: > Hi, > > I'm trying out building some stuff using plc4j/modbus and I have some > questions about that. > > I created a very simple test that connects using modbus-tcp and retrieves > some registers. > Essentially it is this example (using the latest snapshot) but with modbus > https://plc4x.apache.org/users/getting-started/plc4j.html > So I use this connect string "modbus-tcp:tcp://127.0.0.1:1502" and > request ModbusTag.of("3x00001:UINT[100]"). > > The problem I have is that after the data has been read and printed (which > works as expected) the application does not terminate. > > > In the console I see (among other things) at the start: > 12:17:11,811 [INFO ] PlcDriverManager : 48: > Instantiating new PLC Driver Manager with class loader > jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7 > 12:17:11,813 [INFO ] PlcDriverManager : 52: > Registering available drivers... > 12:17:11,818 [INFO ] PlcDriverManager : 59: > Registering driver for Protocol modbus-ascii (Modbus ASCII) > 12:17:11,819 [INFO ] PlcDriverManager : 59: > Registering driver for Protocol modbus-rtu (Modbus RTU) > 12:17:11,820 [INFO ] PlcDriverManager : 59: > Registering driver for Protocol modbus-tcp (Modbus TCP) > 12:17:11,921 [INFO ] TcpChannelFactory : 60: > Configuring Bootstrap with ModbusTcpConfiguration{requestTimeout=5000, > unitIdentifier=1} > > and after my application finished > > 12:17:18,022 [INFO ] NettyChannelFactory : 150: > Channel is closed, closing worker Group also > 12:17:20,025 [INFO ] NettyChannelFactory : 154: > Worker Group was closed successfully! > > and then it just waits... > > When using the debugger in IntelliJ I press pause and have a look at the > threads it seems to me it is stuck in some kind of cleanup I do not > understand. > There is actually a thread called DestroyJavaVM so sounds like outside of > my actual application. > > How do I fix this? > > -- > Best regards / Met vriendelijke groeten, > > Niels Basjes > -- Best regards / Met vriendelijke groeten, Niels Basjes
