mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-06-11 17:12:47 +02:00
Fix gRPC/WS hang because of ALPN
https://feedback.yaak.app/p/grpc-stalls-at-inspecting-schema-no-timeout-no-manual-proto
This commit is contained in:
@@ -111,7 +111,7 @@ pub async fn send_http_request<R: Runtime>(
|
|||||||
.referer(false)
|
.referer(false)
|
||||||
.tls_info(true);
|
.tls_info(true);
|
||||||
|
|
||||||
let tls_config = yaak_http::tls::get_config(workspace.setting_validate_certificates);
|
let tls_config = yaak_http::tls::get_config(workspace.setting_validate_certificates, true);
|
||||||
client_builder = client_builder.use_preconfigured_tls(tls_config);
|
client_builder = client_builder.use_preconfigured_tls(tls_config);
|
||||||
|
|
||||||
match settings.proxy {
|
match settings.proxy {
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ use hyper_util::client::legacy::Client;
|
|||||||
use hyper_util::rt::TokioExecutor;
|
use hyper_util::rt::TokioExecutor;
|
||||||
use tonic::body::BoxBody;
|
use tonic::body::BoxBody;
|
||||||
|
|
||||||
|
// I think ALPN breaks this because we're specifying http2_only
|
||||||
|
const WITH_ALPN: bool = false;
|
||||||
|
|
||||||
pub(crate) fn get_transport(validate_certificates: bool) -> Client<HttpsConnector<HttpConnector>, BoxBody> {
|
pub(crate) fn get_transport(validate_certificates: bool) -> Client<HttpsConnector<HttpConnector>, BoxBody> {
|
||||||
let tls_config = yaak_http::tls::get_config(validate_certificates);
|
let tls_config = yaak_http::tls::get_config(validate_certificates, WITH_ALPN);
|
||||||
|
|
||||||
let mut http = HttpConnector::new();
|
let mut http = HttpConnector::new();
|
||||||
http.enforce_http(false);
|
http.enforce_http(false);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use rustls::{ClientConfig, DigitallySignedStruct, SignatureScheme};
|
|||||||
use rustls_platform_verifier::BuilderVerifierExt;
|
use rustls_platform_verifier::BuilderVerifierExt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub fn get_config(validate_certificates: bool) -> ClientConfig {
|
pub fn get_config(validate_certificates: bool, with_alpn: bool) -> ClientConfig {
|
||||||
let arc_crypto_provider = Arc::new(ring::default_provider());
|
let arc_crypto_provider = Arc::new(ring::default_provider());
|
||||||
let config_builder = ClientConfig::builder_with_provider(arc_crypto_provider)
|
let config_builder = ClientConfig::builder_with_provider(arc_crypto_provider)
|
||||||
.with_safe_default_protocol_versions()
|
.with_safe_default_protocol_versions()
|
||||||
@@ -19,8 +19,11 @@ pub fn get_config(validate_certificates: bool) -> ClientConfig {
|
|||||||
.with_custom_certificate_verifier(Arc::new(NoVerifier))
|
.with_custom_certificate_verifier(Arc::new(NoVerifier))
|
||||||
.with_no_client_auth()
|
.with_no_client_auth()
|
||||||
};
|
};
|
||||||
// Required for http/2 support
|
|
||||||
client.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
|
if with_alpn {
|
||||||
|
client.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
|
||||||
|
}
|
||||||
|
|
||||||
client
|
client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,19 @@ use tokio_tungstenite::tungstenite::handshake::client::Response;
|
|||||||
use tokio_tungstenite::tungstenite::http::HeaderValue;
|
use tokio_tungstenite::tungstenite::http::HeaderValue;
|
||||||
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
|
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
|
||||||
use tokio_tungstenite::{
|
use tokio_tungstenite::{
|
||||||
connect_async_tls_with_config, Connector, MaybeTlsStream, WebSocketStream,
|
Connector, MaybeTlsStream, WebSocketStream, connect_async_tls_with_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Enabling ALPN breaks websocket requests
|
||||||
|
const WITH_ALPN: bool = false;
|
||||||
|
|
||||||
pub(crate) async fn ws_connect(
|
pub(crate) async fn ws_connect(
|
||||||
url: &str,
|
url: &str,
|
||||||
headers: HeaderMap<HeaderValue>,
|
headers: HeaderMap<HeaderValue>,
|
||||||
validate_certificates: bool,
|
validate_certificates: bool,
|
||||||
) -> crate::error::Result<(WebSocketStream<MaybeTlsStream<TcpStream>>, Response)> {
|
) -> crate::error::Result<(WebSocketStream<MaybeTlsStream<TcpStream>>, Response)> {
|
||||||
info!("Connecting to WS {url}");
|
info!("Connecting to WS {url}");
|
||||||
let tls_config = yaak_http::tls::get_config(validate_certificates);
|
let tls_config = yaak_http::tls::get_config(validate_certificates, WITH_ALPN);
|
||||||
|
|
||||||
let mut req = url.into_client_request()?;
|
let mut req = url.into_client_request()?;
|
||||||
let req_headers = req.headers_mut();
|
let req_headers = req.headers_mut();
|
||||||
@@ -34,4 +37,4 @@ pub(crate) async fn ws_connect(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok((stream, response))
|
Ok((stream, response))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
|
|||||||
return (
|
return (
|
||||||
<VStack className="flex-col-reverse mb-3" space={3}>
|
<VStack className="flex-col-reverse mb-3" space={3}>
|
||||||
{/* Buttons on top so they get focus first */}
|
{/* Buttons on top so they get focus first */}
|
||||||
<HStack space={2} justifyContent="start" className="flex-row-reverse">
|
<HStack space={2} justifyContent="start" className="flex-row-reverse mt-3">
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="border"
|
variant="border"
|
||||||
@@ -135,9 +135,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
|
|||||||
<table className="w-full divide-y divide-surface-highlight">
|
<table className="w-full divide-y divide-surface-highlight">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th />
|
<th className="text-text-subtlest" colSpan={3}>Added File Paths</th>
|
||||||
<th className="text-text-subtlest">Added File Paths</th>
|
|
||||||
<th />
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-surface-highlight">
|
<tbody className="divide-y divide-surface-highlight">
|
||||||
|
|||||||
Reference in New Issue
Block a user