Skip to content

Network requests done from the exapps, ocs or otherwise can fail randomly #365

Open
@kyteinsky

Description

@kyteinsky

Describe the bug

We have personally faced this and received 2 issues about it thus far and sort of solved it by retrying the requests.

Alexander suspected this issue might be related to HTTP/2 and with keeping persistent connections alive for too long.
From the HTTP/2 docs in httpx, HTTP/2 is not enabled by default and needs to be installed and used explicitly.
But still the server's connection closure error does not make sense. If we were using HTTP/1.1, we should have been good?

Possible resolutions if we're using HTTP/2 include (untested)

  1. increasing the duration for which the connection lives but that can vary based on the proxy
  2. increasing the size of the connection pool

There is a recommendation of a competing library in nextcloud/stt_whisper2#35
https://github.com/jawah/niquests
It seems to be fastest among the other well-known libraries and supports HTTP/3 if we ever want to start supporting that.

Steps/Code to Reproduce

Cannot be reliably reproduced but suspected to show itself when HTTP/2 is used.
Perform a httpx request like https://github.com/nextcloud/context_chat_backend/blob/3165b55eced1f9462191867230d2542ce66528ce/context_chat_backend/models/nc_texttotext.py#L117 or https://github.com/nextcloud/stt_whisper2/blob/377944ad81fc33fcdced3830a22f58b877b2c2f4/lib/main.py#L98 so the same instance is used for longer periods of time.

Expected Results

No error since this even happens in local network.

Actual Results

httpx.RemoteProtocolError raised in most cases.

Setup configuration

nc_py_api = latest
nextcloud = latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions