Occasional ChunkedEncodingError: Response ended prematurely when calling Nano Banana Pro (OpenAI-compatible) #843

Closed
opened 2026-02-16 10:20:41 -05:00 by yindo · 1 comment
Owner

Originally created by @wbext on GitHub (Dec 1, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.1

Plugin version

0.0.24

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I'm using this plugin to call the Nano Banana Pro model, which is compatible with the OpenAI Chat format. However, an error occasionally occurs:[openai_api_compatible] Error: req_id: 4c7139a7a3 PluginInvokeError: {"args":{},"error_type":"ChunkedEncodingError","message":"Response ended prematurely"}
This error is not 100% reproducible and has no fixed trigger conditions, so I'm unsure of its root cause. When this error occurs, the Nano Banana Pro model's invocation logs show no record of the model being called. Therefore, the issue should originate from the requester side.

✔️ Error log

Image
Originally created by @wbext on GitHub (Dec 1, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Plugin version 0.0.24 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I'm using this plugin to call the Nano Banana Pro model, which is compatible with the OpenAI Chat format. However, an error occasionally occurs:[openai_api_compatible] Error: req_id: 4c7139a7a3 PluginInvokeError: {"args":{},"error_type":"ChunkedEncodingError","message":"Response ended prematurely"} This error is not 100% reproducible and has no fixed trigger conditions, so I'm unsure of its root cause. When this error occurs, the Nano Banana Pro model's invocation logs show no record of the model being called. Therefore, the issue should originate from the requester side. ### ✔️ Error log <img width="453" height="735" alt="Image" src="https://github.com/user-attachments/assets/3d88809b-d61a-47b6-8dbb-da058bb87a5e" />
yindo added the bug label 2026-02-16 10:20:41 -05:00
yindo closed this issue 2026-02-16 10:20:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 1, 2025):

This error is a known intermittent issue in self-hosted Docker setups with OpenAI-compatible plugins. It happens when the HTTP streaming response is interrupted—often due to network hiccups, proxy buffering, or timeout settings—before the model is actually invoked, which is why you see no logs on the Nano Banana Pro side. The error is raised inside the HTTP client (openai/httpx) and surfaces as a PluginInvokeError when the stream ends prematurely (detailsdetails).

Troubleshooting steps:

  1. Increase timeouts in your Docker .env and docker-compose.yaml:
    • Set GUNICORN_TIMEOUT, NGINX_PROXY_READ_TIMEOUT, NGINX_PROXY_SEND_TIMEOUT, PLUGIN_MAX_EXECUTION_TIMEOUT, and DIFY_BACKWARDS_INVOCATION_READ_TIMEOUT to higher values (e.g., 600s or more). Restart your Docker stack after changes (reference).
  2. Disable proxy buffering in NGINX:
    • In your NGINX config (often docker/nginx/proxy.conf.template), ensure you have:
      proxy_buffering off;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      proxy_read_timeout 3600s;
      proxy_send_timeout 3600s;
      
      Reload or restart NGINX after editing (reference).
  3. Check Docker networking:
    • Make sure all containers (api, plugin_daemon, etc.) are on the same Docker network and use service names (not IPs) for inter-container calls. Avoid attaching containers to multiple networks unless necessary (reference).
  4. Increase Uvicorn keep-alive if running plugins or model servers directly:
    • Use --timeout-keep-alive 120 or higher.
  5. Enable debug logging:
    • Set LOG_LEVEL=DEBUG and (optionally) LOG_FILE in your .env to capture detailed logs. Logs are usually at /app/logs/server.log inside the container (reference).
  6. Test streaming behavior:
    • Use curl --no-buffer or browser dev tools to check if chunks are arriving or if responses are buffered.
  7. Try disabling streaming:
    • Forcing "stream": false in the plugin code can avoid this error, but this requires a code change since it's not exposed in the UI (reference).
  8. Consider alternative plugins:
    • If the issue persists, try a different OpenAI-compatible plugin like Regolo.ai, which has more robust streaming support (reference).

Most often, the root cause is proxy buffering or a timeout closing the stream before the model is called. Adjusting these settings usually resolves the issue. If you need step-by-step help with any config, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 1, 2025): <!-- Answer --> This error is a known intermittent issue in self-hosted Docker setups with OpenAI-compatible plugins. It happens when the HTTP streaming response is interrupted—often due to network hiccups, proxy buffering, or timeout settings—before the model is actually invoked, which is why you see no logs on the Nano Banana Pro side. The error is raised inside the HTTP client (openai/httpx) and surfaces as a PluginInvokeError when the stream ends prematurely ([details](https://github.com/langgenius/dify-official-plugins/issues/1781), [details](https://github.com/langgenius/dify/issues/28795#issuecomment-3585389959)). **Troubleshooting steps:** 1. **Increase timeouts** in your Docker `.env` and `docker-compose.yaml`: - Set `GUNICORN_TIMEOUT`, `NGINX_PROXY_READ_TIMEOUT`, `NGINX_PROXY_SEND_TIMEOUT`, `PLUGIN_MAX_EXECUTION_TIMEOUT`, and `DIFY_BACKWARDS_INVOCATION_READ_TIMEOUT` to higher values (e.g., 600s or more). Restart your Docker stack after changes ([reference](https://github.com/langgenius/dify/issues/28795#issuecomment-3585389959)). 2. **Disable proxy buffering** in NGINX: - In your NGINX config (often `docker/nginx/proxy.conf.template`), ensure you have: ``` proxy_buffering off; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_read_timeout 3600s; proxy_send_timeout 3600s; ``` Reload or restart NGINX after editing ([reference](https://github.com/langgenius/dify/discussions/25399#discussioncomment-14347211)). 3. **Check Docker networking**: - Make sure all containers (api, plugin_daemon, etc.) are on the same Docker network and use service names (not IPs) for inter-container calls. Avoid attaching containers to multiple networks unless necessary ([reference](https://github.com/langgenius/dify/issues/27660#issuecomment-3471039009)). 4. **Increase Uvicorn keep-alive** if running plugins or model servers directly: - Use `--timeout-keep-alive 120` or higher. 5. **Enable debug logging**: - Set `LOG_LEVEL=DEBUG` and (optionally) `LOG_FILE` in your `.env` to capture detailed logs. Logs are usually at `/app/logs/server.log` inside the container ([reference](https://github.com/langgenius/dify-official-plugins/issues/1528#issuecomment-3199397782)). 6. **Test streaming behavior**: - Use `curl --no-buffer` or browser dev tools to check if chunks are arriving or if responses are buffered. 7. **Try disabling streaming**: - Forcing `"stream": false` in the plugin code can avoid this error, but this requires a code change since it's not exposed in the UI ([reference](https://github.com/langgenius/dify-official-plugins/issues/1781#issuecomment-3344637749)). 8. **Consider alternative plugins**: - If the issue persists, try a different OpenAI-compatible plugin like Regolo.ai, which has more robust streaming support ([reference](https://github.com/langgenius/dify-official-plugins/issues/1781#issuecomment-3344637749)). Most often, the root cause is proxy buffering or a timeout closing the stream before the model is called. Adjusting these settings usually resolves the issue. If you need step-by-step help with any config, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/beb9374d-70db-4ecb-84a6-9c11d2bf641a?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20is%20a%20known%20intermittent%20issue%20in%20self-hosted%20Docker%20setups%20with%20OpenAI-compatible%20plugins.%20It%20happens%20when%20the%20HTTP%20streaming%20response%20is%20interrupted%E2%80%94often%20due%20to%20network%20hiccups%2C%20proxy%20buffering%2C%20or%20timeout%20settings%E2%80%94before%20the%20model%20is%20actually%20invoked%2C%20which%20is%20why%20you%20see%20no%20logs%20on%20the%20Nano%20Banana%20Pro%20side.%20The%20error%20is%20raised%20inside%20the%20HTTP%20client%20%28openai/httpx%29%20and%20surfaces%20as%20a%20PluginInvokeError%20when%20the%20stream%20ends%20prematurely%C2%A0%28%5Bdetails%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1781%29%2C%C2%A0%5Bdetails%5D%28https%3A//github.com/langgenius/dify/issues/28795%23issuecomment-3585389959%29%29.%0A%0A%2A%2ATroubleshooting%20steps%3A%2A%2A%0A%0A1.%20%2A%2AIncrease%20timeouts%2A%2A%20in%20your%20Docker%20%60.env%60%20and%20%60docker-compose.yaml%60%3A%0A%20%20%20-%20Set%20%60GUNICORN_TIMEOUT%60%2C%20%60NGINX_PROXY_READ_TIMEOUT%60%2C%20%60NGINX_PROXY_SEND_TIMEOUT%60%2C%20%60PLUGIN_MAX_EXECUTION_TIMEOUT%60%2C%20and%20%60DIFY_BACKWARDS_INVOCATION_READ_TIMEOUT%60%20to%20higher%20values%20%28e.g.%2C%20600s%20or%20more%29.%20Restart%20your%20Docker%20stack%20after%20changes%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/28795%23issuecomment-3585389959%29%29.%0A2.%20%2A%2ADisable%20proxy%20buffering%2A%2A%20in%20NGINX%3A%0A%20%20%20-%20In%20your%20NGINX%20config%20%28often%20%60docker/nginx/proxy.conf.template%60%29%2C%20ensure%20you%20have%3A%0A%20%20%20%20%20%60%60%60%0A%20%20%20%20%20proxy_buffering%20off%3B%0A%20%20%20%20%20proxy_http_version%201.1%3B%0A%20%20%20%20%20proxy_set_header%20Connection%20%22%22%3B%0A%20%20%20%20%20proxy_read_timeout%203600s%3B%0A%20%20%20%20%20proxy_send_timeout%203600s%3B%0A%20%20%20%20%20%60%60%60%0A%20%20%20%20%20Reload%20or%20restart%20NGINX%20after%20editing%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/discussions/25399%23discussioncomment-14347211%29%29.%0A3.%20%2A%2ACheck%20Docker%20networking%2A%2A%3A%0A%20%20%20-%20Make%20sure%20all%20containers%20%28api%2C%20plugin_daemon%2C%20etc.%29%20are%20on%20the%20same%20Docker%20network%20and%20use%20service%20names%20%28not%20IPs%29%20for%20inter-container%20calls.%20Avoid%20attaching%20containers%20to%20multiple%20networks%20unless%20necessary%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/27660%23issuecomment-3471039009%29%29.%0A4.%20%2A%2AIncrease%20Uvicorn%20keep-alive%2A%2A%20if%20running%20plugins%20or%20model%20servers%20directly%3A%0A%20%20%20-%20Use%20%60--timeout-keep-alive%20120%60%20or%20higher.%0A5.%20%2A%2AEnable%20debug%20logging%2A%2A%3A%0A%20%20%20-%20Set%20%60LOG_LEVEL%3DDEBUG%60%20and%20%28optionally%29%20%60LOG_FILE%60%20in%20your%20%60.env%60%20to%20capture%20detailed%20logs.%20Logs%20are%20usually%20at%20%60/app/logs/server.log%60%20inside%20the%20container%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1528%23issuecomment-3199397782%29%29.%0A6.%20%2A%2ATest%20streaming%20behavior%2A%2A%3A%0A%20%20%20-%20Use%20%60curl%20--no-buffer%60%20or%20browser%20dev%20tools%20to%20check%20if%20chunks%20are%20arriving%20or%20if%20responses%20are%20buffered.%0A7.%20%2A%2ATry%20disabling%20streaming%2A%2A%3A%0A%20%20%20-%20Forcing%20%60%22stream%22%3A%20false%60%20in%20the%20plugin%20code%20can%20avoid%20this%20error%2C%20but%20this%20requires%20a%20code%20change%20since%20it%27s%20not%20exposed%20in%20the%20UI%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1781%23issuecomment-3344637749%29%29.%0A8.%20%2A%2AConsider%20alternative%20plugins%2A%2A%3A%0A%20%20%20-%20If%20the%20issue%20persists%2C%20try%20a%20different%20OpenAI-compatible%20plugin%20like%20Regolo.ai%2C%20which%20has%20more%20robust%20streaming%20support%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1781%23issuecomment-3344637749%29%29.%0A%0AMost%20often%2C%20the%20root%20cause%20is%20proxy%20buffering%20or%20a%20timeout%20closing%20the%20stream%20before%20the%20model%20is%20called.%20Adjusting%20these%20settings%20usually%20resolves%20the%20issue.%20If%20you%20need%20step-by-step%20help%20with%20any%20config%2C%20let%20me%20know%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2157)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#843