rhttp icon indicating copy to clipboard operation
rhttp copied to clipboard

Getting H3_INTERNAL_ERROR on calling via h3 preference

Open rajat-ventura opened this issue 1 year ago • 13 comments

I am calling NGINX with http3 enabled and cronet is working fine as well as a request client. We are doing a PoC and are trying to use rhttp instead because of its speed. Could you please check if my implementation is wrong?

` rAuthInvest = await RhttpCompatibleClient.create( interceptors: [TimeInterceptor()], settings: ClientSettings( httpVersionPref: HttpVersionPref.http3, timeoutSettings: TimeoutSettings( timeout: Duration(seconds: 30), connectTimeout: Duration(seconds: 10), keepAliveTimeout: Duration(seconds: 60), ), throwOnStatusCode: true, ) );

Future orderbookHeaders( {Function(dynamic data)? onSuccess, Function(dynamic error)? onError, Map<String, String> headers = const {}, Map requestData = const {}}) async {

try {
  Map<String, String> h = {
  "Content-type": "application/json",
  "Access-Control-Allow-Origin": "*",
  "User-Agent": "Dart/3.4",
  // "Accept-Encoding": ['gzip', 'br'],
  "Authorization": "Bearer ${prefUtils.getAuthtoken()}",
  "session_id": prefUtils.getSsoSessionId(),
  "x-client-id": prefUtils.getclientid(),
};
  var response;
  try {
    response = await HTTP3.rAuthInvest.post(
        Uri.parse("$ordersUrl/txn/orderbook/v1/header"),
        headers: h,
        body: jsonEncode(requestData));
  } catch(e) {
    print(e.toString());
  }
  if (response.statusCode < 400 && onSuccess != null) {
    onSuccess(response.body);
  } else {
    onError!(
      response.bodyMap.containsKey("message")
          ? response.bodyMap["message"]
          : 'Something Went Wrong!',
    );
  }
} catch (error) {
  onError!(error);
}

} `

Screenshot 2024-10-26 at 11 07 26 AM

any support would be really helpful

rajat-ventura avatar Oct 26 '24 05:10 rajat-ventura

I just dug a bit deeper and this line is throwing the error

final rustResponse = await responseCompleter.future; in request.dart line 160 Screenshot 2024-10-26 at 11 52 56 AM

rajat-ventura avatar Oct 26 '24 06:10 rajat-ventura

H3_INTERNAL_ERROR seems like an error on the Rust side.

Tienisto avatar Oct 26 '24 11:10 Tienisto

is there any way i can look into the RCA on what was wrong from my end? and maybe try to fix it

rajat-ventura avatar Oct 28 '24 03:10 rajat-ventura

An option would be to run write the exact request in Rust to check if Rhttp doesn't do anything wrong. If it still occurs, then maybe there is a solution in reqwest or h3 Github repo.

Tienisto avatar Oct 28 '24 10:10 Tienisto

can resolve by this: image https://github.com/hyperium/h3/issues/206?spm=5176.2020520104.0.0.6ffb43ecFgRJC2

denonzhu avatar Dec 17 '24 06:12 denonzhu

Thanks @denonzhu did your suggested changes work, if you tried changing on a fork or something?

scoobhidu avatar Dec 17 '24 07:12 scoobhidu

work for me ,you can do it like this: image image image image

denonzhu avatar Dec 17 '24 07:12 denonzhu

thanks for the help @denonzhu, i'll try it next week once I resume my work

meanwhile @Tienisto can you please check if we can upgrade the version of reqwest crate? because I can see in their master branch they have removed the grease dependency

Uploading Screenshot 2024-12-17 at 1.21.13 PM.png…

scoobhidu avatar Dec 17 '24 07:12 scoobhidu

Hello @scoobhidu , your screenshot is unfortunately not loading.

Rhttp already uses the latest version (0.12.9) https://github.com/Tienisto/rhttp/blob/main/rhttp%2Frust%2FCargo.toml#L17

I am thinking of adding the workaround by @denonzhu but I am not sure if it has bad side effects or if we should wait if the issue is fixed by h3.

Tienisto avatar Dec 17 '24 08:12 Tienisto

oh sorry @Tienisto, the screenshot was of https://github.com/seanmonstar/reqwest/blob/master/src/async_impl/h3_client/connect.rs

the file does not contain the grease dependency in remote_connect method as highlighted in denonzhu's screenshot

scoobhidu avatar Dec 17 '24 08:12 scoobhidu

@denonzhu's suggested fix seems to be working as from H3_INTERNAL_ISSUE I have now started getting another issue where I keep getting this

V/reqwest::async_impl::..( 4760): did not find connection ("http", invest.venturasecurities.uat) in pool so connecting...
I/flutter ( 4760): http://invest.venturasecurities.uat/market/v1/mktstatus Time taken: 2
I/flutter ( 4760): [RhttpUnknownException] reqwest::Error { kind: Request, source: "HTTP/3 connecting already in progress for (\"http\", invest.venturasecurities.uat)" }

This keeps happening on a loop with recurrent requests and same error

Can you please help in resolving this?

scoobhidu avatar Dec 19 '24 06:12 scoobhidu

hi @Tienisto

I tried building the same logic using reqwest

let client = Client::builder()
    .http3_prior_knowledge()
    .build()?;

let response = client
    .get("https://http3.venturasecurities.com/indices/v1/viewall")
    .headers(headers)
    .send()
    .await?;

I get the following response Error: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("http3.venturasecurities.com")), port: None, path: "/indices/v1/viewall", query: None, fragment: None }, source: hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: AlertReceived(NoApplicationProtocol) } }) }

scoobhidu avatar Jan 05 '25 08:01 scoobhidu

You should reach out for https://github.com/seanmonstar/reqwest Errors in reqwest are out of scope in rhttp.

Tienisto avatar Jan 06 '25 17:01 Tienisto