Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'holochain-weekly' into bump-0.3.0-dev.48
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme authored Apr 26, 2024
2 parents 03d6460 + f7b7aab commit b025a53
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/hc_launch/src-tauri/src/launch_tauri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use holochain_launcher_utils::window_builder::{happ_window_builder, UISource};
use holochain_types::websocket::AllowedOrigins;
use std::collections::HashMap;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::path::PathBuf;
use tauri::utils::config::AppUrl;
use tauri::Manager;
Expand Down Expand Up @@ -334,8 +335,7 @@ async fn get_app_websocket(admin_port: String) -> Result<u16, String> {
.map_err(|e| format!("Failed to parse admin port String to u16: ${}", e))?;

// Try to connect twice. This fixes the os(111) error for now that occurs when the conducor is not ready yet.
let mut ws = match AdminWebsocket::connect(SocketAddr::from(([127, 0, 0, 1], parsed_port))).await
{
let mut ws = match AdminWebsocket::connect(socket_address_from_port(parsed_port)).await {
Ok(ws) => ws,
Err(e) => return Err(format!("Could not connect to admin websocket: {:?}", e)),
};
Expand Down Expand Up @@ -400,3 +400,19 @@ fn sanitize_app_id(app_id: String) -> String {
.replace(" ", "-")
.replace(".", "_");
}

fn socket_address_from_port(port: u16) -> SocketAddr {
match format!("localhost:{port}").to_socket_addrs() {
Ok(mut socket_addrs) => match socket_addrs.next() {
Some(addr) => addr,
None => {
println!("[hc launch] ERROR: Could not resolve localhost");
panic!("Could not resolve localhost.");
}
},
Err(e) => {
println!("[hc launch] ERROR: Could not resolve localhost");
panic!("Could not resolve localhost.");
}
}
}

0 comments on commit b025a53

Please sign in to comment.