Skip to content

Commit 7acc914

Browse files
authored
Merge pull request #107 from livechat/API-13015/fix-rtm-repsonses-handling
check if push type is equal to response in WebsocketClient send method
2 parents e59cf6c + e19850c commit 7acc914

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
1313

1414
### Bugfixes
1515
- Fix HTTP request type for `get_product_source` method in Configuration API v3.5 and v3.6.
16+
- Fix an issue related to fetching responses in RTM.
1617

1718
## [0.3.6] - 2023-03-09
1819

livechat/utils/ws_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ def send(self,
8181
if not self.sock or self.sock.send(request_json, opcode) == 0:
8282
raise WebSocketConnectionClosedException(
8383
'Connection is already closed.')
84-
while not (response := next((item for item in self.messages
85-
if item.get('request_id') == request_id),
86-
None)) and response_timeout > 0:
84+
while not (response := next(
85+
(item
86+
for item in self.messages if item.get('request_id') == request_id
87+
and item.get('type') == 'response'),
88+
None)) and response_timeout > 0:
8789
sleep(0.2)
8890
response_timeout -= 0.2
8991
self.logger.info(f'\nRESPONSE:\n{json.dumps(response, indent=4)}')

0 commit comments

Comments
 (0)