Getting http request to work with HTTP 0.9

Greetings;

Just started playing with Node Red on my brand new Rpi 4. I was able to read information from an Arduino running a simple web server without a problem. Now, I'm trying to get Node Red to display some information from a webserver running on my solar panel data unit. It runs http 0.9.

In python, I get the following code to produce results:

import socket
from io import BytesIO

conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
conn.connect(('192.168.10.212', 80))
conn.send(b'GET /hometable.xml\r\n')
buffer = BytesIO()
while True:
    chunk = conn.recv(4096)
    if chunk:
        buffer.write(chunk)
    else:
        break
data = buffer.getvalue().decode("utf-8")
parsed = data.split(';')
kW = float(parsed[0])
kWh = float(parsed[2])
print(kW, "kW")
print(kWh, "kWh")
# print (data)

But in http request, I haven't been able to find a space, where to put

b'GET /hometable.xml\r\n'

Cheers

What do you mean by this? Are you sure you really mean that? This is the very first version of the HTTP protocol and certainly should never be used now. It is highly insecure for one thing. It also doesn't support any of the expected more advanced HTTP features.

I very much doubt that node.js supports it either which is probably why it is failing since Node-RED is build on node.js.

The minimum recommended version of HTTP that you should be using is v1.2

Here is a confirmation for you of what I'm saying: https://stackoverflow.com/a/40846902/1309986

Hello TI;

Well, I'm not sure that it is 0.9, but that is what this post says:

And, using 0.9, I can access the hometable.xml (not really XML either) with both my Arduino and my Python sketch...

It is not my choice that this Hoymiles unit is using 0.9... I looked for an updated firmware, but there is none to be had...

It sits behind my firewall, but it does somehow communicate with a cloud server...

Do I read you correctly that Node-Red will not be able to communicate with this device?

Cheers

There is one notice - this file is available thru old HTTP/0.9 protocol. to download it using curl you must use additional flag --http0.9

You have to use curl, you cannot use node.js

It is a cr**py old piece of kit that hasn't had an update - probably ever. Make sure you keep it well away from the Internet.

Or use TCP. Nick did an example some time back. I'll see if I can find it.

Here : Basic Fetch Error - #26 by knolleary

Thanks Steve;

I'm too new to Node-Red to understand

So, I ran the HTML node just entering the address of the DTU in it, and I get this response in the debug, just in case there is a solution for this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<TITLE>Hoymiles</TITLE>
<SCRIPT>
function getData(url) {
	var xmlhttp;
	if (window.XMLHttpRequest) {
  		xmlhttp=new XMLHttpRequest();
  	} else {
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function() {
  		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    		alertContents1(xmlhttp.responseText);
    	}
  	}
	xmlhttp.open('GET',url + '?_t=' + new Date().getTime(),true);
	xmlhttp.send(null);
}
setInterval("getData('hometable.xml')", 3000);
function alertContents1(text)
{
          var t = 0;
          var j = 0;
          var k = 0;
          var temp;
          var str;
          var ss;
          var Rssi_Value = "";
		   var arr = text.split(";");
          document.getElementById("outpw").innerHTML = arr[0] + " kW";
          document.getElementById("tetot").innerHTML = arr[...

I'm really only interested in the first 4 or 5 data fields in there (the debug somehow only shows the first 2, "outpw" and "tetot")

If I can't get this running, I guess I could have my little Arduino get the data out of it and present it to Node-Red on the same Web-page that it already can read. "Kludge" comes to mind...

Cheers

OK, so this tells you that you can bypass the page that you are requesting and directly ask for the XML.

So if the address you are currently getting is something like http://1.2.3.4/index.html, replace that with http://1.2.3.4/hometable.xml?_t= followed by a number that represents the current time, that's what the new Date().getTime() gives you. You can get node-red to deliver that.

When you have the XML, there is a node to convert that to a JavaScript object. Dump the output to debug and you will be able to find the values you are looking for.

Thanks!

But, I had just done a apt full-upgrade, and now I'm getting

Failed to execute child process “xterm” (No such file or directory)

when I try to start Node-Red.

Followed

https://nodered.org/docs/getting-started/raspberrypi

but the same error persists...

Until I did this in /usr/bin:

sudo cp lxterminal xterm

Back to http 0.9:

So, in the HTTP node's URL, I put:

http://192.168.10.212/hometable.xml?_t=new Date().getTime()

And I get an "HPE_INVALID_CONSTANT" error.

I know, I'm a bloody beginner in Node-Red, so if you can point me towards remedial training, or just help me out with this one...

Thanks a bunch!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.