issue: offline ollama host prevents open-webui from loading entirely #4494

Closed
opened 2025-11-11 15:55:24 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @taylorwilsdon on GitHub (Mar 19, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

0.5.20

Ollama Version (if applicable)

all

Operating System

all

Browser (if applicable)

all

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

If an ollama host configured in the Connections panel becomes unresponsive, the models that it serves should become unavailable/disappear from the selection list and the connection should be marked as offline, but open-webui should continue to be responsive and usable. This is how it works with OpenAI API Connections but with Ollama connections, it refuses to paint the UI if the connection cannot be established.

Actual Behavior

When an enabled ollama host becomes unreachable (even just because it fell asleep), open-webui takes minutes to load and sometimes never will because the get_all_models timeout is longer than the http timeout.

Video confirming behavior - always reproducible:

https://github.com/user-attachments/assets/8616bfe8-89ec-4e70-ad8c-8c79ffb2e45f

2025-03-19 15:13:27.617 | ERROR    | open_webui.routers.ollama:send_get_request:98 - Connection error: Cannot connect to host marcel.local:11434 ssl:default [Connect call failed ('10.0.1.212', 11434)] - {}```

```2025-03-19 15:11:32.825 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:63204 - "GET /api/models HTTP/1.1" 200 - {}
2025-03-19 15:11:51.755 | ERROR    | asyncio.runners:run:118 - Task exception was never retrieved
future: <Task finished name='Task-601645' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1114> exception=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data for satisfy transfer length header.'>")> - {}
Traceback (most recent call last):

  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_proto.py", line 92, in connection_lost
    uncompleted = self._parser.feed_eof()
                  │    └ None
                  └ <aiohttp.client_proto.ResponseHandler object at 0xffff7e997bd0>
  File "aiohttp/_http_parser.pyx", line 508, in aiohttp._http_parser.HttpParser.feed_eof
    raise TransferEncodingError(
          └ <class 'aiohttp.http_exceptions.TransferEncodingError'>

aiohttp.http_exceptions.TransferEncodingError: 400, message:
  Not enough data for satisfy transfer length header.


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

> File "/app/backend/open_webui/utils/middleware.py", line 1719, in post_response_handler
    await stream_body_handler(response)
          │                   └ <starlette.responses.StreamingResponse object at 0xffff7ef10a50>
          └ <function process_chat_response.<locals>.post_response_handler.<locals>.stream_body_handler at 0xffff7eacf4c0>

  File "/app/backend/open_webui/utils/middleware.py", line 1471, in stream_body_handler
    async for line in response.body_iterator:
              │       │        └ <async_generator object convert_streaming_response_ollama_to_openai at 0xffff7da896d0>
              │       └ <starlette.responses.StreamingResponse object at 0xffff7ef10a50>
              └ 'data: {"id": "gemma3:27b-efd61f45-e646-4e3a-9958-6067ab3a20b6", "created": 1742397111, "model": "gemma3:27b", "choices": [{"...

  File "/app/backend/open_webui/utils/response.py", line 103, in convert_streaming_response_ollama_to_openai
    async for data in ollama_streaming_response.body_iterator:
              │       │                         └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
              │       └ <starlette.responses.StreamingResponse object at 0xffff7f8c4890>
              └ {'id': 'gemma3:27b-efd61f45-e646-4e3a-9958-6067ab3a20b6', 'created': 1742397111, 'model': 'gemma3:27b', 'choices': [{'index':...

  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__
    rv = await self.read_func()
               │    └ <member 'read_func' of 'AsyncStreamIterator' objects>
               └ <aiohttp.streams.AsyncStreamIterator object at 0xffff7fd5bbe0>
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline
    return await self.readuntil()
                 │    └ <function StreamReader.readuntil at 0xffffb7c52980>
                 └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 386, in readuntil
    await self._wait("readuntil")
          │    └ <function StreamReader._wait at 0xffffb7c52840>
          └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ...
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 347, in _wait
    await waiter
          └ <Future finished exception=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not e...

aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed: <TransferEncodingError: 400, message='Not enough data for satisfy transfer length header.'>```

### Steps to Reproduce

1. Go to Connections and add a working ollama host.
2. Shut down the ollama host.
3. Try to access Open-WebUI.

### Logs & Screenshots

https://github.com/user-attachments/assets/23335c7a-6b82-4caa-b0f2-f8f3187d23c5

### Additional Information

I will cut a PR to resolve the issue. 
Originally created by @taylorwilsdon on GitHub (Mar 19, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version 0.5.20 ### Ollama Version (if applicable) all ### Operating System all ### Browser (if applicable) all ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior If an ollama host configured in the `Connections` panel becomes unresponsive, the models that it serves should become unavailable/disappear from the selection list and the connection should be marked as offline, but open-webui should continue to be responsive and usable. This is how it works with `OpenAI API Connections` but with Ollama connections, it refuses to paint the UI if the connection cannot be established. ### Actual Behavior When an enabled ollama host becomes unreachable (even just because it fell asleep), open-webui takes minutes to load and sometimes never will because the `get_all_models` timeout is longer than the http timeout. Video confirming behavior - always reproducible: https://github.com/user-attachments/assets/8616bfe8-89ec-4e70-ad8c-8c79ffb2e45f ```2025-03-19 15:13:26.617 | ERROR | open_webui.routers.ollama:send_get_request:98 - Connection error: Cannot connect to host marcel.local:11434 ssl:default [Connect call failed ('10.0.1.212', 11434)] - {} 2025-03-19 15:13:27.617 | ERROR | open_webui.routers.ollama:send_get_request:98 - Connection error: Cannot connect to host marcel.local:11434 ssl:default [Connect call failed ('10.0.1.212', 11434)] - {}``` ```2025-03-19 15:11:32.825 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:63204 - "GET /api/models HTTP/1.1" 200 - {} 2025-03-19 15:11:51.755 | ERROR | asyncio.runners:run:118 - Task exception was never retrieved future: <Task finished name='Task-601645' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1114> exception=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data for satisfy transfer length header.'>")> - {} Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/client_proto.py", line 92, in connection_lost uncompleted = self._parser.feed_eof() │ └ None └ <aiohttp.client_proto.ResponseHandler object at 0xffff7e997bd0> File "aiohttp/_http_parser.pyx", line 508, in aiohttp._http_parser.HttpParser.feed_eof raise TransferEncodingError( └ <class 'aiohttp.http_exceptions.TransferEncodingError'> aiohttp.http_exceptions.TransferEncodingError: 400, message: Not enough data for satisfy transfer length header. The above exception was the direct cause of the following exception: Traceback (most recent call last): > File "/app/backend/open_webui/utils/middleware.py", line 1719, in post_response_handler await stream_body_handler(response) │ └ <starlette.responses.StreamingResponse object at 0xffff7ef10a50> └ <function process_chat_response.<locals>.post_response_handler.<locals>.stream_body_handler at 0xffff7eacf4c0> File "/app/backend/open_webui/utils/middleware.py", line 1471, in stream_body_handler async for line in response.body_iterator: │ │ └ <async_generator object convert_streaming_response_ollama_to_openai at 0xffff7da896d0> │ └ <starlette.responses.StreamingResponse object at 0xffff7ef10a50> └ 'data: {"id": "gemma3:27b-efd61f45-e646-4e3a-9958-6067ab3a20b6", "created": 1742397111, "model": "gemma3:27b", "choices": [{"... File "/app/backend/open_webui/utils/response.py", line 103, in convert_streaming_response_ollama_to_openai async for data in ollama_streaming_response.body_iterator: │ │ └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ... │ └ <starlette.responses.StreamingResponse object at 0xffff7f8c4890> └ {'id': 'gemma3:27b-efd61f45-e646-4e3a-9958-6067ab3a20b6', 'created': 1742397111, 'model': 'gemma3:27b', 'choices': [{'index':... File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__ rv = await self.read_func() │ └ <member 'read_func' of 'AsyncStreamIterator' objects> └ <aiohttp.streams.AsyncStreamIterator object at 0xffff7fd5bbe0> File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline return await self.readuntil() │ └ <function StreamReader.readuntil at 0xffffb7c52980> └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ... File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 386, in readuntil await self._wait("readuntil") │ └ <function StreamReader._wait at 0xffffb7c52840> └ <StreamReader e=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not enough data ... File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 347, in _wait await waiter └ <Future finished exception=ClientPayloadError("Response payload is not completed: <TransferEncodingError: 400, message='Not e... aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed: <TransferEncodingError: 400, message='Not enough data for satisfy transfer length header.'>``` ### Steps to Reproduce 1. Go to Connections and add a working ollama host. 2. Shut down the ollama host. 3. Try to access Open-WebUI. ### Logs & Screenshots https://github.com/user-attachments/assets/23335c7a-6b82-4caa-b0f2-f8f3187d23c5 ### Additional Information I will cut a PR to resolve the issue.
GiteaMirror added the bug label 2025-11-11 15:55:24 -06:00
Author
Owner

@tjbck commented on GitHub (Mar 19, 2025):

AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST is available to change this behaviour.

f806ab0bd2 should address this.

@tjbck commented on GitHub (Mar 19, 2025): `AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST` is available to change this behaviour. f806ab0bd295bbf6feb50d4512f5e1f3d9dcf9cf should address this.
Author
Owner

@taylorwilsdon commented on GitHub (Mar 19, 2025):

Oh amazing that was literally the PR I was about to open (setting a default instead of none) you're too fast for me! :ty:

Image
@taylorwilsdon commented on GitHub (Mar 19, 2025): Oh amazing that was literally the PR I was about to open (setting a default instead of none) you're too fast for me! :ty: <img width="691" alt="Image" src="https://github.com/user-attachments/assets/e7a9be6f-cba2-4233-8dd7-daafbf84c382" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#4494