Skip to content

Commit 7a55901

Browse files
Acknowledge client/server protocol split
1 parent 0d889c1 commit 7a55901

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

replit_river/client_transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
RiverException,
1919
)
2020
from replit_river.messages import (
21-
PROTOCOL_VERSION,
21+
CLIENT_PROTOCOL_VERSION,
2222
FailedSendingMessageException,
2323
WebsocketClosedException,
2424
parse_transport_msg,
@@ -227,7 +227,7 @@ async def _send_handshake_request(
227227
) -> ControlMessageHandshakeRequest[HandshakeMetadataType]:
228228
handshake_request = ControlMessageHandshakeRequest[HandshakeMetadataType](
229229
type="HANDSHAKE_REQ",
230-
protocolVersion=PROTOCOL_VERSION,
230+
protocolVersion=CLIENT_PROTOCOL_VERSION,
231231
sessionId=session_id,
232232
metadata=handshake_metadata,
233233
expectedSessionState=expected_session_state,

replit_river/messages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class FailedSendingMessageException(Exception):
2929
pass
3030

3131

32-
PROTOCOL_VERSION = "v1.1"
32+
CLIENT_PROTOCOL_VERSION = "v2.0"
33+
SERVER_PROTOCOL_VERSION = "v1.1"
3334

3435

3536
async def send_transport_message(

replit_river/server_transport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from websockets.exceptions import ConnectionClosed
1111

1212
from replit_river.messages import (
13-
PROTOCOL_VERSION,
13+
SERVER_PROTOCOL_VERSION,
1414
FailedSendingMessageException,
1515
WebsocketClosedException,
1616
parse_transport_msg,
@@ -209,15 +209,15 @@ async def _establish_handshake(
209209
)
210210
raise InvalidMessageException("failed validate handshake request") from e
211211

212-
if handshake_request.protocolVersion != PROTOCOL_VERSION:
212+
if handshake_request.protocolVersion != SERVER_PROTOCOL_VERSION:
213213
await self._send_handshake_response(
214214
request_message,
215215
HandShakeStatus(ok=False, reason="protocol version mismatch"),
216216
websocket,
217217
)
218218
error_str = (
219219
"protocol version mismatch: "
220-
+ f"{handshake_request.protocolVersion} != {PROTOCOL_VERSION}"
220+
+ f"{handshake_request.protocolVersion} != {SERVER_PROTOCOL_VERSION}"
221221
)
222222
raise InvalidMessageException(error_str)
223223
if request_message.to != self._transport_id:

0 commit comments

Comments
 (0)