From d39e532e4b95a7689a7f258824ed26b8469acf63 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 10 Jan 2020 15:01:36 +0000 Subject: [PATCH] Improving websocket connection errors --- clients/nym-client/src/sockets/ws.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clients/nym-client/src/sockets/ws.rs b/clients/nym-client/src/sockets/ws.rs index 2669fb9c90..59bebfadbd 100644 --- a/clients/nym-client/src/sockets/ws.rs +++ b/clients/nym-client/src/sockets/ws.rs @@ -6,6 +6,7 @@ use futures::channel::{mpsc, oneshot}; use futures::future::FutureExt; use futures::io::Error; use futures::{SinkExt, StreamExt}; +use log::*; use serde::{Deserialize, Serialize}; use sphinx::route::{Destination, DestinationAddressBytes}; use std::io; @@ -64,7 +65,7 @@ impl From for ClientRequest { Message::Close(_) => panic!("todo: handle close!"), _ => panic!("Other types of messages are also unsupported!"), }; - serde_json::from_str(&text_msg).unwrap() + serde_json::from_str(&text_msg).expect("unable to deserialize From json") } } @@ -105,6 +106,7 @@ impl ClientRequest { async fn handle_fetch(mut msg_query: mpsc::UnboundedSender) -> ServerResponse { let (res_tx, res_rx) = oneshot::channel(); if msg_query.send(res_tx).await.is_err() { + warn!("Failed to handle_fetch. msg_query.send() is an error."); return ServerResponse::Error { message: "Server failed to receive messages".to_string(), }; @@ -113,6 +115,7 @@ impl ClientRequest { let messages = res_rx.map(|msg| msg).await; if messages.is_err() { + warn!("Failed to handle_fetch. messages is an error"); return ServerResponse::Error { message: "Server failed to receive messages".to_string(), }; @@ -196,6 +199,7 @@ async fn accept_connection( self_address: DestinationAddressBytes, topology: Topology, ) { + warn!("accept_connection"); let address = stream .peer_addr() .expect("connected streams should have a peer address");