Skip to main content

client

Function client 

Source
pub fn client() -> Result<Client, Error>
Expand description

Build a [reqwest::Client] for talking to XMTP HTTP endpoints.

Prefer this over reqwest::Client::new() anywhere in the workspace: on Android a default-built client aborts the process the first time it opens a TLS connection. reqwest 0.13 reaches for rustls-platform-verifier whenever no explicit roots are configured, and that verifier calls into the JVM on Android. It panics with Expect rustls-platform-verifier to be initialized unless the host application initializes it over JNI with a Context and also ships the crate’s Kotlin component. libxmtp is consumed as a plain .so through uniffi, so that initialization never happens, and an HTTP request could take the whole app down on its first TLS connection.

So on Android we hand reqwest a rustls config built from the bundled webpki roots and the platform verifier is never constructed. This mirrors xmtp_api_grpc, which already forces webpki roots for the gRPC channel on Android and iOS.

Other platforms keep reqwest’s default behaviour: the platform verifier works there without any initialization, and it honours user- and enterprise-installed CAs.