Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the title above -->
<!--- Link the corresponding issues after you created the pull request
-->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [x] I have updated the [changelog](../CHANGELOG.md) accordingly.
- [ ] I have added tests to cover my changes.

Closes Draegerwerk#287 Draegerwerk#289
  • Loading branch information
deichmab-draeger authored Nov 27, 2023
1 parent 35af6fb commit 7777eed
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sdc11073/consumer/consumerimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/sdc11073/provider/porttypes/contextserviceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 7 additions & 2 deletions src/sdc11073/pysoap/soapclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -186,15 +189,17 @@ 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."""
with self._lock:
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()
Expand Down

0 comments on commit 7777eed

Please sign in to comment.