diff --git a/CHANGELOG.md b/CHANGELOG.md index 416da9d6..fe7a5c80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - basic_logging_setup only handles sdc logger, no more side effect due to calling logging.basicConfig. +- fixed wrong response for SetContextState message. [#287](https://github.com/Draegerwerk/sdc11073/issues/287 +- fixed connection problem when provider closes socket after first request. [#289](https://github.com/Draegerwerk/sdc11073/issues/289 ### Changed - change python classes of `addressing_types.py` to match ws-addressing standard of 2006 instead of 2004 diff --git a/src/sdc11073/consumer/consumerimpl.py b/src/sdc11073/consumer/consumerimpl.py index c90fdd9f..cc4becb2 100644 --- a/src/sdc11073/consumer/consumerimpl.py +++ b/src/sdc11073/consumer/consumerimpl.py @@ -446,7 +446,7 @@ def start_all(self, not_subscribed_actions: Iterable[str] | None = None, self._mk_hosted_services(self.host_description) self._logger.debug('Services: {}', self._service_clients.keys()) # noqa: PLE1205 - used_ip = self.get_soap_client(self._device_location).sock.getsockname()[0] + used_ip = self.get_soap_client(self._device_location).sock_name[0] self._network_adapter = network.get_adapter_containing_ip(used_ip) self._logger.info('SdcConsumer for {} uses network adapter {}', # noqa: PLE1205 self._device_location, diff --git a/src/sdc11073/provider/porttypes/contextserviceimpl.py b/src/sdc11073/provider/porttypes/contextserviceimpl.py index 37291dc1..0582755d 100644 --- a/src/sdc11073/provider/porttypes/contextserviceimpl.py +++ b/src/sdc11073/provider/porttypes/contextserviceimpl.py @@ -56,7 +56,7 @@ def _on_set_context_state(self, request_data): data_model = self._sdc_definitions.data_model msg_node = request_data.message_data.p_msg.msg_node set_context_state = data_model.msg_types.SetContextState.from_node(msg_node) - response = data_model.msg_types.ActivateResponse() + response = data_model.msg_types.SetContextStateResponse() return self._handle_operation_request(request_data, set_context_state, response) def _on_get_context_states(self, request_data): diff --git a/src/sdc11073/pysoap/soapclient.py b/src/sdc11073/pysoap/soapclient.py index 3ee292e5..5678e29e 100644 --- a/src/sdc11073/pysoap/soapclient.py +++ b/src/sdc11073/pysoap/soapclient.py @@ -68,6 +68,8 @@ def __repr__(self) -> str: class SoapClientProtocol(Protocol): """The expected interface of a soap client.""" + sock_name: tuple[str, int] | None + def __init__(self, netloc: str, socket_timeout: int | float, @@ -158,6 +160,7 @@ def __init__(self, self._lock = Lock() self._chunk_size = chunk_size self._has_connection_error = False # used to avoid implicit connects after an error + self.sock_name: tuple[str, int] | None = None @property def netloc(self) -> str: @@ -186,8 +189,9 @@ def connect(self): self._has_connection_error = False self._http_connection = self._mk_http_connection() self._http_connection.connect() # connect now so that we have own address and port for logging - my_addr = self._http_connection.sock.getsockname() - self._log.info('soap client No. {} uses connection={}:{}', self._client_number, my_addr[0], my_addr[1]) + self.sock_name = self._http_connection.sock.getsockname() + self._log.info('soap client No. {} uses connection={}:{}', + self._client_number, self.sock_name[0], self.sock_name[1]) def close(self): """Close connection.""" @@ -195,6 +199,7 @@ def close(self): self._close_without_lock() def _close_without_lock(self): + self.sock_name = None if self._http_connection is not None: self._log.info('closing soapClientNo {} for {}', self._client_number, self._netloc) self._http_connection.close()