# Ollama streaming response on ignition

**URL:** <https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [November 7, 2025, 9:46am UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028 "2025-11-07T09:46:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayushvarma9081](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@ayushvarma9081](https://forum.inductiveautomation.com/u/ayushvarma9081)\
**Post date:** [November 7, 2025, 9:46am UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028/1 "2025-11-07T09:46:36Z")

</div>

I’m trying to integrate **Ollama (a local LLM server)** with **Ignition’s Web Dev module** to get **real-time streaming responses** instead of waiting for the full reply. My current script works fine with `"stream": false` using `HttpURLConnection`, but I can’t get `"stream": true` working. How can I safely implement **asynchronous or streaming HTTP responses** in Ignition so clients receive data progressively?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 7, 2025, 4:55pm UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028/2 "2025-11-07T16:55:13Z")

</div>

I'm confused.

WebDev is used to write HTTP **API** s, for consumption by other HTTP clients.

If you're trying to talk to Ollama, presumably Ignition **is** the HTTP client (and Ollama is the API), so the WebDev module is not involved.

Assuming I'm not completely misunderstanding you, then what you want is `system.net.httpClient` (not `HttpURLConnection` - that API is unpleasant to use). If you use `system.net.httpClient().getJavaClient()` you get access to the underlying [`java.net.HttpClient`](https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/HttpClient.html).  
You can invoke an HTTP request manually and provide your own "body handler" that does whatever you want with the input response; see [`BodyHandlers`](https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/HttpResponse.BodyHandlers.html).

This is a case where an LLM would actually probably do okay, with guardrails - ask your LLM de jure for a Jython script, using Python 2.7 syntax, preferring **Java** imports, that uses Java's standard library net httpclient to consume a streaming response.

I don't know anything about Ollama's API or how it separates chunks of data - that will be another thing for you to figure out.

Good luck.

---

<div class="post-metadata">

**Author:** ![ayushvarma9081](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@ayushvarma9081](https://forum.inductiveautomation.com/u/ayushvarma9081)\
**Post date:** [November 8, 2025, 9:33am UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028/3 "2025-11-08T09:33:44Z")

</div>

Thanks for response,

The main underlying issue is Java’s `HttpClient.send()` is **blocking** — it waits until the full response is complete before returning control to Jython.

- It **buffers** the response internally.

- You get all the lines **after** the HTTP connection closes.

- So you can iterate over `resp.body()` — but that’s **post-stream** , not _while_ the stream is coming in.

* * *

### What _True_ Streaming Would Require

To get **actual live streaming** (i.e., each chunk arrives as soon as Ollama emits it), you must:

1. Use **`sendAsync()`** instead of `send()`, and

2. Provide a **custom body subscriber** that processes chunks as they come in.

For example (in Java):

```python
client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream())
    .thenAccept(response -> {
        InputStream is = response.body();
        // read from InputStream continuously
    });

```

But…

> ⚠ Ignition’s Jython (2.7 + JVM sandbox) **cannot easily consume async Java Futures** or attach reactive callbacks.

So, i need a **Java thread** that continuously reads the `InputStream` and prints chunks as they arrive  
Thanks!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 10, 2025, 4:29pm UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028/4 "2025-11-10T16:29:10Z")

</div>

I'm not going to debate further with your large language model.

Anything you can write in Java you can write in Jython. You can absolutely consume a streaming response via Jython, by translating that exact same Java code you have into Jython.

---

<div class="post-metadata">

**Author:** ![ayushvarma9081](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@ayushvarma9081](https://forum.inductiveautomation.com/u/ayushvarma9081)\
**Post date:** [November 12, 2025, 9:56am UTC](https://forum.inductiveautomation.com/t/ollama-streaming-response-on-ignition/112028/5 "2025-11-12T09:56:49Z")

</div>

Thanks a lot for the documentation of [`java.net.HttpClient`](https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/HttpClient.html) it helped me connect to my server with streaming response.

thanks again for help!
