opcua: Server connection loss is not propageted up to session
I’m currently testing edge cases against a small python server setup. When killing the server process and restarting it, the client does not seem to be able to reconnect. That said, I’m not quite sure, whether it notices that the server has been disconnected. Is there anyway to catch this? (I tried the connection state changed and session closed callbacks, but they’re not being called though).
Log output:
2019-01-25 10:54:40.071 - INFO - opcua_client::comms::tcp_transport - ReadState has dropped
2019-01-25 10:54:40.071 - INFO - opcua_client::comms::tcp_transport - Read loop finished
2019-01-25 10:54:41.581 - ERROR - opcua_client::comms::tcp_transport - Write IO error Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
2019-01-25 10:54:41.582 - ERROR - opcua_client::comms::tcp_transport - Write loop is finished with an error ()
2019-01-25 10:54:41.582 - INFO - opcua_client::comms::tcp_transport - WriteState has dropped
2019-01-25 10:55:09.579 - INFO - opcua_client::session_state - Making secure channel request
2019-01-25 10:55:09.579 - INFO - opcua_client::session_state - security_mode = None
2019-01-25 10:55:09.579 - INFO - opcua_client::session_state - security_policy = None
2019-01-25 10:55:19.608 - INFO - opcua_client::session_state - Timeout waiting for response from server
2019-01-25 10:55:19.609 - INFO - opcua_client::message_queue - Request 53 has timed out and any response will be ignored
2019-01-25 10:55:19.609 - INFO - opcua_client::session_state - Making secure channel request
2019-01-25 10:55:19.609 - INFO - opcua_client::session_state - security_mode = None
2019-01-25 10:55:19.609 - INFO - opcua_client::session_state - security_policy = None
The making secure channel request with sec mode and policy endlessly loop after that point.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (15 by maintainers)
And one other piece of work:
I’ll take a look at this tonight and see if I can reproduce. If it’s just a case of setting a flag in the map_err() then it should be relatively simple to bring down the other tasks by setting the connection state to finished.
e.g.
set_connection_state!(connection_state, ConnectionState::Finished(BadConnectionClosed);
This probably has to be done in the reader and writer, but only if the connection state is not already in a finished state.
When the connection state is set to Finished, the Session::is_connected() returns false, which should mean the reconnect_and_activate() code gets called. This code hasn’t been finished so it will probably reveal other errors that need to be fixed.
I put some session disconnect / retry / reconnect code into the crate but it doesn’t work fully yet.