Application/x-ndjson

im integrating against ollama and need to read "node red application/x-ndjson" stream from ollama.

tested this with the core http-request node but it refuses to stream the response. i just get a timeout. or everything at once.

tested various other contrib nodes but could just find ones that only support GET request. i need to POST.

Anyone have a good solution to this?
i could always create a external app for this but prefair to have it in node-red.

http-in and http-out nodes do not support http streaming.

The http-out node will close the connection after it has sent the first message it receives from the http-in node.

Sorry, misread.

But the same answer applies, the http-request node does not support HTTP streaming.

You can adjust the timeout in the settings.js with the httpRequestTimeout field or msg.requestTimeout

Hi @svefro

Try sending a RAW request via the TCP Request Node

  • Send a valid (Correctly formatted) HTTP request using the TCP Request Node
    (keeping the connection open - Never - Keep connection open)

RAW HTTP Request example (Send to a TCP Request Node)

/* Adjust accordingly */
const HTTPRequest = [
    'POST /SOME/URI HTTP/1.1',
    'Host: XXXXX:XXXXX',
    'Content-Type: application/json'
    'Accept: application/x-ndjson\r\n'
    '{SomeJSON}'
]

msg.payload = HTTPRequest.join('\r\n')
return msg

This, I believe should give you streaming (untested)

I dont know the protocol, so adjust the request according to its requirements (POST v GET, with a body etc etc) - might need to check my code - it was a quick write

Thanks for pointing me to a tcp node. :slight_smile:

i used this (got badrequest without content length):

const body = JSON.stringify({ model: "deepseek-r1:8b" });

const HTTPRequest = [
    'POST /api/pull HTTP/1.1',
    'Host: 192.168.1.100',
    'Content-Type: application/json',
    'Accept: application/x-ndjson',
    'Content-Length: ' + Buffer.byteLength(body),
    '', // required blank line
    body
];

msg.payload = HTTPRequest.join('\r\n');

return msg;

and it worked :slight_smile:

but in the meantime i tested using curl in an exec node and got some strange errors:

when using exec mode it works as expected, but in spawn mode i get a bunch of errors:

any idea what is causing this??

Anyway i'll stick with the raw http request way. Thanks again :slight_smile: