@@ -165,8 +165,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
165165 & mut self ,
166166 client_update : Result < Message , Error > ,
167167 ) -> Result < ( ) , IcWsError > {
168- // upon receiving an update while the session is Setup, check if it is due to
169- // the client disconnecting without a closing handshake
168+ // upon receiving an update, check if the message is valid and is not a close message
170169 let ws_message = self . check_client_update ( client_update) ?;
171170 if ws_message. is_close ( ) && !self . session_state . is_closed ( ) {
172171 trace ! ( "Client disconnected while in {} state" , self . session_state) ;
@@ -179,7 +178,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
179178 // upon receiving a message while the session is Init, check if the message is valid
180179 // if not return an error, otherwise set the session state to Setup
181180 // if multiple messages are received while in Init state, 'handle_setup_transition' will
182- // return an error as the client shall not send more than one message while in Init state
181+ // ignore them as the client shall not send more than one message while in Init state
183182 let setup_state = self . handle_setup_transition ( ws_message) . await ?;
184183 self . session_state = setup_state;
185184 } ,
@@ -244,7 +243,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
244243 // this implies a bug in the WS Gateway
245244 error ! ( "Received canister message while in Closed state" ) ;
246245 Err ( IcWsError :: IcWsProtocol ( String :: from (
247- "Poller shall not be able tosend messages while the session is in Closed state" ,
246+ "Poller shall not be able to send messages while the session is in Closed state" ,
248247 ) ) )
249248 } ,
250249 }
@@ -290,17 +289,14 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
290289 Ok ( ( client_key, canister_id) ) => {
291290 // replace the field with the canister_id received in the first envelope
292291 // this shall not be updated anymore
293- // if canister_id is already set in the struct, we return an error as inspect_ic_ws_open_message shall only be called once
292+ // if canister_id is already set in the struct, we log a warning as inspect_ic_ws_open_message shall only be called once
294293 if self . canister_id . replace ( canister_id) . is_some ( )
295294 || self . client_key . replace ( client_key. clone ( ) ) . is_some ( )
296295 {
297296 // if the canister_id or client_key field was already set,
298297 // it means that the client sent the WS open message twice,
299298 // which it shall not do
300- // therefore, return an error
301- return Err ( IcWsError :: IcWsProtocol ( String :: from (
302- "canister_id or client_key field was set twice" ,
303- ) ) ) ;
299+ warn ! ( "canister_id or client_key field was set twice" ) ;
304300 }
305301 trace ! ( "Validated WS open message" ) ;
306302
@@ -370,7 +366,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin> ClientSession<S> {
370366 // relay the envelope to the IC
371367 self . relay_envelope_to_canister ( serialized_envelope, canister_id) ;
372368
373- // there is no need to relay the response back to the client as the response to a request to the /call enpoint is not certified by the canister
369+ // there is no need to relay the response back to the client as the response to a request to the /call endpoint is not certified by the canister
374370 // and therefore could be manufactured by the gateway
375371
376372 trace ! ( "Relayed client message to canister" ) ;
0 commit comments