artificialbrains-sdk 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ab_sdk/client.py CHANGED
@@ -122,7 +122,15 @@ class ABClient:
122
122
  # derive host root from base_url (/api stripped)
123
123
  url = self.base_url[:-4] if self.base_url.endswith("/api") else self.base_url
124
124
 
125
- socket = socketio.Client(reconnection=True, logger=False, engineio_logger=False)
125
+ socket = socketio.Client(
126
+ reconnection=True,
127
+ reconnection_attempts=0, # infinite retries
128
+ reconnection_delay=1,
129
+ reconnection_delay_max=5,
130
+ logger=True, # Enable to see ping/pong
131
+ engineio_logger=True,
132
+ request_timeout=3600, # Allow long requests (1 hour)
133
+ )
126
134
 
127
135
  connect_headers: Dict[str, str] = {}
128
136
  auth_payload: Optional[Dict[str, Any]] = None
@@ -136,49 +144,23 @@ class ABClient:
136
144
  # Helpful visibility: log namespace connect/disconnect
137
145
  @socket.on("connect", namespace=ns)
138
146
  def _on_connect():
139
- logger.info("Realtime connected to namespace %s (namespaces=%s)", ns, list(getattr(socket, "namespaces", {}).keys()))
147
+ logger.info("Realtime connected to namespace %s", ns)
140
148
 
141
149
  @socket.on("disconnect", namespace=ns)
142
150
  def _on_disconnect():
143
151
  logger.warning("Realtime disconnected from namespace %s", ns)
144
152
 
145
- # Robust connect strategy:
146
- # 1) Try websocket-only (does NOT require `requests`)
147
- # 2) Fallback to default transports (polling+websocket) if needed
148
- # Provide a clear error message if dependencies are missing.
149
- try:
150
- socket.connect(
151
- url,
152
- headers=connect_headers,
153
- auth=auth_payload,
154
- namespaces=[ns],
155
- transports=["websocket"],
156
- wait=True,
157
- wait_timeout=self.timeout,
158
- )
159
- except Exception as e1:
160
- # If websocket-client is missing, python-socketio will fail here.
161
- # If polling is needed and `requests` is missing, it will fail on fallback.
162
- try:
163
- socket.connect(
164
- url,
165
- headers=connect_headers,
166
- auth=auth_payload,
167
- namespaces=[ns],
168
- wait=True,
169
- wait_timeout=self.timeout,
170
- )
171
- except Exception as e2:
172
- msg = (
173
- "Realtime connection failed.\n\n"
174
- "Tried websocket-only then default transports.\n\n"
175
- "Common fixes:\n"
176
- " - pip install websocket-client\n"
177
- " - pip install requests\n\n"
178
- f"websocket error: {e1}\n"
179
- f"fallback error: {e2}"
180
- )
181
- raise socketio.exceptions.ConnectionError(msg)
153
+ # Use polling + websocket (not websocket-only)
154
+ # This maintains connection through NAT devices
155
+ socket.connect(
156
+ url,
157
+ headers=connect_headers,
158
+ auth=auth_payload,
159
+ namespaces=[ns],
160
+ transports=["polling", "websocket"], # MUST have polling first!
161
+ wait=True,
162
+ wait_timeout=120,
163
+ )
182
164
 
183
165
 
184
166
  # HARD ASSERT: the namespace must actually be connected, or emits will fail with:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artificialbrains_sdk
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: ArtificialBrains Python SDK
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: Other/Proprietary License
@@ -1,5 +1,5 @@
1
1
  ab_sdk/__init__.py,sha256=tYSMwbFzqsiZ7Bp7mYy2kQ0rX9I1NwM6wS1hEGYuze4,1831
2
- ab_sdk/client.py,sha256=TvANQpuEgjDYn51tIcXtGijHrqFUVXKPGXjKMRbWflc,10144
2
+ ab_sdk/client.py,sha256=Aj5XgAEBtXeKg5DQgdG66SNtOvTYugd9DROkw34GmEY,9220
3
3
  ab_sdk/contract_scaffold.py,sha256=4zcsWhd9axxMu--FZ7U8B8u4QLUwluifyvqac2apDno,8930
4
4
  ab_sdk/endpoints.py,sha256=yc4h_E8vQA9TmWF0sW2GprgE0QnS3eBetH13ogeuw4E,2102
5
5
  ab_sdk/input_streamer.py,sha256=fRPlBimaTDBsm1gz9cdoYanVbmwYTBXSyI9IrXslXiM,6847
@@ -9,7 +9,7 @@ ab_sdk/plugins/__init__.py,sha256=veHfKqvymY8YPN9HF4E1S4pwRUcVVJHDAyBZptbLNlA,18
9
9
  ab_sdk/plugins/decoder.py,sha256=vHAubiAPOaOg3J006TLjn4qAoLIu2Lz2D2kjz421odc,10148
10
10
  ab_sdk/plugins/deviation.py,sha256=QLKOqOSa9HIj3Z3bO6oR79wY1Lni_P-j3GAGM7UYKVs,2019
11
11
  ab_sdk/plugins/reward.py,sha256=E5IsV29N6juyfIQ7ZksDa8JSxAAbVflaJOtLplilAD4,1796
12
- artificialbrains_sdk-0.1.4.dist-info/METADATA,sha256=m7pUtsi0xBlVHDzB2qEHkzxuHKTxm--2g0-9tLwIGFM,12177
13
- artificialbrains_sdk-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
14
- artificialbrains_sdk-0.1.4.dist-info/top_level.txt,sha256=Ttsz2oF0qRh68OI9w3mu_LKkv2I_YvOWr3kudSpckpM,7
15
- artificialbrains_sdk-0.1.4.dist-info/RECORD,,
12
+ artificialbrains_sdk-0.1.5.dist-info/METADATA,sha256=mu2eo9FmI8BgPKrOTE7h6INcLlwTNGFYKFQpaOCHFSo,12177
13
+ artificialbrains_sdk-0.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
14
+ artificialbrains_sdk-0.1.5.dist-info/top_level.txt,sha256=Ttsz2oF0qRh68OI9w3mu_LKkv2I_YvOWr3kudSpckpM,7
15
+ artificialbrains_sdk-0.1.5.dist-info/RECORD,,