You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "T. Langhorst (Jira)" <ji...@apache.org> on 2020/03/12 14:56:00 UTC

[jira] [Created] (PLC4X-188) Connection doesn't close

T. Langhorst created PLC4X-188:
----------------------------------

             Summary: Connection doesn't close
                 Key: PLC4X-188
                 URL: https://issues.apache.org/jira/browse/PLC4X-188
             Project: Apache PLC4X
          Issue Type: Bug
          Components: Driver-Modbus
    Affects Versions: 0.6.0
            Reporter: T. Langhorst


I use the following code:

{code:java}
String connectionString = "modbus:tcp://localhost:502";

try(PlcConnection connection = new PlcDriverManager().getConnection(connectionString)) {
    if (!connection.getMetadata().canRead()) {
        System.out.println("This connection doesn't support reading.");
        return;
    }

    PlcReadRequest request = connection.readRequestBuilder()
         .addItem("c1", "coil:1")
         .build();
    PlcReadResponse resp = request.execute().get();
    boolean coil = resp.getBoolean("c1");
    System.out.println("Status of coil 1: " + coil);
} catch (InterruptedException | ExecutionException | PlcConnectionException e) {
    e.printStackTrace();
}
{code}

But the program just doesn't exit after the request is finished.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)