Http Response not receiving data

Hi Ian (@IanH),

Thought it would become very dramatic to analyze your issue, but unexpectedly it seemed to be rather simple. Below the steps that I have done, in case someone else ever runs into the same problem.

As you mentioned the stream could be retrieved by the browser, by simply navigating to the php file on your server:

So I checked in the Chrome developer tools the corresponding traffic, more specific the content-type of the http response:

image

Seemed to be Server-Sent events, an alternative to WebSockets for sending a stream of events fromt the server to the client, which means we need our Node-Red flow to act as a client (instead of the browser), so we need a Node-Red alternative for the browser's EventSource Javascript API. Luckely the eventsource node does the job for us, and we are even more lucky because there seems already a Node-Red contribution available that wraps this node: GitHub - lafka/node-red-http-sse: Server sent events support for node-red

Weird, but I couldn't manage to install it via NPM (and Node-Red 'manage palette' shows node-red-contrib-http-sse which also couldn't be installed)? Anyway I installed it directly from Github:

npm install lafka/node-red-http-sse

Added this contribution to my flow (don't forget to specify the path to your php file in the node's config screen):
image

[{"id":"5ca1aa7c.b0ca74","type":"debug","z":"279b8956.27dfe6","name":"SSE messages","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":720,"y":380,"wires":[]},{"id":"2a0260fa.21ec1","type":"http-sse","z":"279b8956.27dfe6","name":"Capture SSE messages","remote":"Path to your php file","events":"message","x":460,"y":380,"wires":[["5ca1aa7c.b0ca74"]]}]

Then the debug node shows your event stream:

image

P.S.1. Don't forget to remove the public link to your server in your router!
P.S.2. If you know how the sse contribution can be installed via NPM, please post the solution here!

Kind regards,
Bart Butenaers

1 Like

Thanks Bart, I installed as you quote above, which worked once in the Node-Red directory and I am getting my data fine. Will have to work out if it will restart the stream should it stop, or I will need to restart it, somehow. A trigger with 30 second of no output into it triggering a HTTP request might do it as http-SSE has no input.
Now to tidy up that payload, in the end it is no JSON, but as all the data is numeric, I might get awat with deleting all "