eclipse / milo

Eclipse Milo™ - an open source implementation of OPC UA (IEC 62541).
http://www.eclipse.org/milo
Eclipse Public License 2.0
1.15k stars 427 forks source link

TCP connection not closed after failing to create a session #868

Closed FSangouard closed 3 years ago

FSangouard commented 3 years ago

Describe the bug When failing to create a session on the OPC UA server because of e.g. bad configuration of certificates, the underlying TCP connection is never closed. Running netstat still shows the connection as ESTABLISHED to the server.

Expected behavior The TCP connection should be closed.

Logs and Packet Captures nifi-app-debug.log

According to the code that runs when the Nifi controller service shuts down... :

public void shutdown() {
        try {
            if (opcClient != null) {
                getLogger().debug("Disconnecting from OPC server...");
                opcClient.disconnect().get(3, TimeUnit.SECONDS);
            }
        } catch (Exception e) {
            getLogger().warn(e.getMessage());
        }
    }

...the last 3 lines of these logs indicate that the disconnect raises an exception. I should mention that in the code above opcClient is an instance of org.eclipse.milo.opcua.sdk.client.OpcUaClient.

Additional context We're using a Nifi OPC UA package that uses Milo 0.2.1. Maybe this issue has already been fixed in later versions. I saw that there were many changes since this version but I'm not sure which one would fix this, if any. Maybe this commit ?

kevinherron commented 3 years ago

I don't know specifically if this was fixed since then, but this does not appear to be an issue in current versions of the client SDK.

FSangouard commented 3 years ago

Thank you for your answer. Is it ok if I leave this issue open for now until we can test with the latest version?

kevinherron commented 3 years ago

Yes I'll leave it open for now. I don't know if you're planning on upgrading the NiFi package or somebody else, but let me know if you have any questions. There have been some significant changes since the 0.2.x releases.