title: OPC-UA BadSecureChannelClosed
body: <p>I have two windows services, one service (service1) connects to two OPC-UA servers, this works fine. The other windows service (service2) connects to the same two OPC-UA servers with identical connection code from OPC-UA foundation's .NET reference stack.</p>
  
  <p>Service1 can connect to both OPC-UA servers and it polls data successfully. During deployment of Service2, Service2 could also connect and read values from both OPC-UA servers. Everything was fine at this point.</p>
  
  <p>However, now after a while, without doing any changes to any code. Service2 can no longer connect to one of the OPC-UA servers, when doing Session.Create it simply replies with ServiceResultException BadSecureChannelClosed(2156265472).</p>
  
  <p>Starting troubleshooting: On our customer site, we also have a test server which runs an identical setup of the setup on the production environment, meaning that Service1 and Service2 also runs on the test server and communicates in identical manner to those two OPC-UA servers.</p>
  
  <p>I have noticed that when I turn off the services on the test server, the BadSecureChannelClosed error of Service2 disappear (however Service2 could still communicate with the other one of two OPC-UA servers). Making everything work as expected on the production server.</p>
  
  <p>This leads me to wonder what limitations of sessions and connections are there on an OPC-UA server. The OPC-UA servers are of type SINUMERIK 840d. I have asked Siemens if its possible to activate the ServerDiagnostics object to troubleshoot amount of Sessions etc, but they replied that this isn't possible. I thought this object was mandatory to be able to enable?</p>
  
  <p>Could anyone give me hints of what could cause this, and what limitations and things I should think about while making the connection, e.g. what needs to be unique? ApplicationName? SessionName? etc. What could cause this - seemingly - "random" BadSecureChannelClosed error. Note that I am using updateBeforeConnect=true in the Create Session call. And I use UserIdentity with hardcoded usernames and password.</p>
  
  <p>Another wierd symptom is that for this OPC-UA server that replies with BadSecureChannelClosed, it gives Discovery error when connecting to it with UaExpert (errors that were not present few weeks ago):</p>
  
  <p>16:58:41.806 | Automatic Update   | Error retrieving current version information: Host updates.unified-automation.com not found</p>
  
  <p>16:58:35.404 | DiscoveryWidget    | Discovery GetEndpoints on opc.tcp://192.168.0.200:4840 failed (BadCommunicationError)</p>
  
  <p>16:58:35.401 | DiscoveryWidget    | Discovery FindServers on opc.tcp://192.168.0.200:4840 failed (BadCommunicationError)</p>