mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
make net ws more robust to test websocket server connection failure
This commit is contained in:
parent
fe2eb732a0
commit
7a75bf73e3
1 changed files with 15 additions and 9 deletions
|
|
@ -415,16 +415,22 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
||||||
#[cfg(feature = "websocket")]
|
#[cfg(feature = "websocket")]
|
||||||
"ws" => {
|
"ws" => {
|
||||||
if self.ws.is_none() {
|
if self.ws.is_none() {
|
||||||
let (socket, response) =
|
let url = url::Url::parse("wss://awake.noskills.club/ws").expect("Can't parse");
|
||||||
tungstenite::connect(url::Url::parse("wss://awake.noskills.club/ws").unwrap()).expect("Can't connect");
|
match tungstenite::connect(url) {
|
||||||
|
Ok((socket, response)) => {
|
||||||
log::info!("Connected to the server");
|
log::info!("Connected to the server");
|
||||||
log::info!("Response HTTP code: {}", response.status());
|
log::info!("Response HTTP code: {}", response.status());
|
||||||
log::info!("Response contains the following headers:");
|
log::info!("Response contains the following headers:");
|
||||||
for (ref header, _value) in response.headers() {
|
for (ref header, _value) in response.headers() {
|
||||||
log::info!("* {}", header);
|
log::info!("* {}", header);
|
||||||
|
}
|
||||||
|
self.ws = Some(socket);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("failed to connect to ws server: {e}");
|
||||||
|
write!(ret, "failed to connect to ws server: {e}").ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.ws = Some(socket);
|
|
||||||
}
|
}
|
||||||
let mut err = false;
|
let mut err = false;
|
||||||
if let Some(socket) = &mut self.ws {
|
if let Some(socket) = &mut self.ws {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue