node-opcua / node-opcua

Unlocking the Full Potential of OPC UA with Typescript and NodeJS - http://node-opcua.github.io/
MIT License
1.45k stars 478 forks source link

connection lost event triggering is taking long time up to 40 seconds #1194

Open raptorsj opened 1 year ago

raptorsj commented 1 year ago

Current behavior i tried to kill my client device and it is taking 45 seconds to respond from node-opcua for triggering connection lost event where as i'm using uaexpert tool for checking the same it is taking less than 10 seconds. is there any way to improve this??

create opcua connection options :
 {
           requestedSessionTimeout: 30000,
            applicationName:  applicationName,
            connectionStrategy:{
                                        "initialDelay": 100,
                                        "maxRetry": 1
                                      },
            securityPolicy: "none"
            securityMode: "none"
            endpointMustExist: false
            keepSessionAlive: true;

}

create subscription options : 
{
   requestedPublishingInterval": 50,
            "requestedLifetimeCount": 100,
            "requestedMaxKeepAliveCount": 10,
            "maxNotificationsPerPublish": 100,
            "publishingEnabled": true,
            "priority": 10
}

Describe the bug

Step by step instruction to reproduce

Steps to reproduce the behavior:

  1. ....
  2. ....
  3. ....

Expected behavior

Screenshots

Gist

gist:

Context

erossignon commented 1 year ago

You should not kill the client but rather properly close the session and disconnect the client using the provided API.

Abruptly killing the client will cause the server to keep the session object on the server side alive for a duration that is defined in the requestedSessionTimeout: 30000 parameter above. (the server may decide to adjust the value to a more appropriate one)

The server keeps the session open on its end in case the disconnection was due to a network outtage to allow the communication to resume seemlessly.

erossignon commented 1 year ago

Some improvements have been made toward detecting socket timeout inside node-opcua@2.101.0 The problem should be fixed now and detection This problem was apparent especially when running node-opuca client inside a docker container

@raptorsj , can you give it a try and tell me if the problem is now fixed on your end with node-opcua@2.102.0 ?

raptorsj commented 1 year ago

will check and update

erossignon commented 4 months ago

@raptorsj: any update ?