Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,7 @@
3.0.20231204 - Mon Dec 4 08:33:47 PST 2023
* Increase client information (provide login user, host and script) for the purpose
of providing teams a way of tracking errors down to origination point

3.0.20240124 - Wed Jan 24 09:27:07 AM PST 2024
* FIX: When using the `websockets` library, capture and handle the `ConnectionClosedError`
properly. Handle reconnect attempt properly and don't trigger a tight error loop
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "swampyer"
description = "Simple WAMP library with minimal external dependencies"
version = '3.0.20231204'
version = '3.0.20240124'
authors = ["Aki Mimoto <aki@zaber.com>"]
packages = [
{ include = "swampyer" }
Expand Down
15 changes: 13 additions & 2 deletions swampyer/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if not os.getenv('SWAMPYER_DISABLE_ALT_WEBSOCKETS_LIBRARY'):
try:
import websockets.sync.client as wsc
import websockets.exceptions as wse
HAS_ALT_WEBSOCKETS_LIBRARY = True
except:
pass
Expand Down Expand Up @@ -222,10 +223,20 @@ def close(self):
return self.socket.close()

def send(self, payload):
self.socket.send(payload)
try:
self.socket.send(payload)
except wse.ConnectionClosedError:
raise ExWAMPConnectionError()
except Exception as ex:
raise ex

def recv_data(self, *a, **kw):
return self.socket.recv()
try:
return self.socket.recv()
except wse.ConnectionClosedError:
raise ExWAMPConnectionError()
except Exception as ex:
raise ex

def next(self):
try:
Expand Down
6 changes: 4 additions & 2 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ def connect_service(
concurrency_max=None,
concurrency_class=None,
concurrency_configs=None,
timeout=None
timeout=None,
username=None
):

snapshot_data = load_nexus_db()
users = snapshot_data['users']

# Try to login manually
username = 'backend-1'
if not username:
username = 'backend-1'
password = users[username]['plaintext_password']

serializers = None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_03_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def sub_capture(event,data):
client2.shutdown()



if __name__ == '__main__':
test_connection()