Hi. Thanks for reading my post. I'm having great luck as a newbie with node-red overall for a project that I'm working on. The one thing I can't seem to figure out is a strange message that comes every now and then from the open TCP port. I'm using custom hardware to send TCP messages, a twelve character string. I've added a function node to try to filter out any of the other messages:
var data = msg.payload;
var len = msg.payload.length;
if (len === 12) {
msg.payload = data;
return msg;
}
It only passes the valid messages intermittently. I am wondering if I have messed up the syntax. Any help would be greatly appreciated. Thank you again for reading.
Also the strange messages coming in look like this:
GET / HTTP/1.1
Host: 161.35.101.114:49153
Connection: close
Accept-Encoding: gzip
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
According to the user agent, the following browser is accessing this resource. Chrome 50 on Mac OS X.
if you have accessed this TCP server through the mentioned browser at some point, its likely trying to ascertain some info about it to help with its "recent" viewed websites or something to that effect.
What you are seeing, is the RAW TCP request sent by a web browser.
The browser will likely freakout, as its expecting a valid HTTP/1.1 response.
Sure I get that. But this is not a standard HTTP port so they’re crawlers. It sort of doesn’t matter what they are or why they are I just need to figure out how to filter them out. I’m using two ports for TCP and they both get messages from crawlers. It seems to be happening more and more often. Any thoughts on why this function mode isn’t working consistently? Any ideas on a general method of filtering out messages from crawlers? Thanks.