Trying to post a LoRa message to my server


I am trying to post a message from the 'lora' node to my server using HTTP. I can see that the msg is ok in the debug window in a paralell msgnode but at my server only garbage charachters arrive.. What am I doing wrong ?

I would like to recive the same message as I can see in the debug window.

Please help a newbie!



What kind of server? Are you sure http is the correct way? Have you tried with a tcp node?



You want to send the entire message object?

If so you will probably need to move it to msg.payload as most node expect the bit of the message you want to do something with there.

Also how have you configured the http-request node?



No I have not but I use the same code to recive messages from TTN ( thethingsnetwork) who use HTTP push. I thought this might have worked in the same way .. but clearly not



This is how I configured the HTTP node.





You still haven't said if you want all the data in your example sent to just the msg.payload data.

You also probably need to set a msg.header for the content type, but hopefully the company provides a example of the data format you should be providing



I want the complete message exatly as in the debug console.. the payload is not enough



then as i suggested before you will have to move it, so that it is an object under msg.payload



Sorry I dont understand what you mean by "so that it is an object under msg.payload" I cant connect any threads to the message obj.. it have no connector.. Please explain more for a newbie..



I have tried TCP node, same thing happens. I want the complete LoRa message as in the debug window



There are multiple things wrong with you current flow.

The http request node won’t send the entire msg, it will only send msg.payload so you need to put everything you want to send “in” msg.payload.

You could either do this as an array or an object and given the data you have you want an object. There are lots of tutorials online for javascript arrays and objects it’s worth reading through one to understand.

You can move things around using a change node

On the httprequest as I said you probably need to set a http message header to explain to the server what you are sending.

It look as if you are sending it to a commercial service? If so there should be some documentation as to what they are expecting, which would be useful.



Please post your msg as text so that it is easy to copy it so we can try your message in a simple flow



I just made a simple example using tcp nodes

From the LoRa node you receive the msg as an object. To be able to send it, you should convert it into a string (for this I would use the json node, it is simple & straight forward). Then the object will be sent to the tcp server, embedded in the msg.payload. When listening to the tcp server, you will receive the msg,payload as a string, now using the json node again, convert it back to an object. From here you can easily access each property and value as you prefer

If you thought of updating a webpage hosted by a webserver, you should instead use websockets to send the msg. When the msg arrives to the webserver, you need to have javascript code in the page that captures it and updates the corresponding element in the html code. But that is another story I assume

Kind regards, Walter



Below is the complete data I recieve from the LoRa node. I want it transfered to my TCP server which has port 3099 open waiting for incoming connections. In the debug window i can se the data, I have tried to use the change node to convert msg.object to json and text but without success :frowning: In the server I just see garbage charachters.

{ "tmst": 2841206956, "chan": 6, "rfch": 1, "freq": 867.7, "stat": 1, "modu": "LORA", "datr": "SF9BW125", "codr": "4/5", "lsnr": 11.5, "rssi": -36, "opts": "", "size": 13, "fcnt": 93, "cls": 0, "port": 5, "mhdr": "40fe8bc001805d00", "appeui": "70-b3-d5-7e-d0-01-44-a1", "deveui": "a8-17-58-ff-fe-03-e4-66", "ack": false, "adr": true, "gweui": "00-80-00-00-a0-00-26-f6", "seqn": 93, "time": "2019-02-17T18:06:14.336536Z", "payload": [ 1, 0, 237, 2, 33, 7, 14, 37, 20, 0, 15, 126, 171 ], "eui": "a8-17-58-ff-fe-03-e4-66", "_msgid": "c744131e.38bbf", "object": "" }



No, no,
You shall NOT use the change node, you shall use the json node. See the example below. Try the flow I have attached, what is shown in your tcp server when you click on the input node?


[{"id":"fe2c106b.19244","type":"inject","z":"5751999a.c509a8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":650,"y":320,"wires":[["930cc7e1.e1b628"]]},{"id":"930cc7e1.e1b628","type":"function","z":"5751999a.c509a8","name":"","func":"var t = { \"tmst\": 2841206956, \"chan\": 6, \"rfch\": 1, \"freq\": 867.7, \"stat\": 1, \"modu\": \"LORA\", \"datr\": \"SF9BW125\", \"codr\": \"4/5\", \"lsnr\": 11.5, \"rssi\": -36, \"opts\": \"\", \"size\": 13, \"fcnt\": 93, \"cls\": 0, \"port\": 5, \"mhdr\": \"40fe8bc001805d00\", \"appeui\": \"70-b3-d5-7e-d0-01-44-a1\", \"deveui\": \"a8-17-58-ff-fe-03-e4-66\", \"ack\": false, \"adr\": true, \"gweui\": \"00-80-00-00-a0-00-26-f6\", \"seqn\": 93, \"time\": \"2019-02-17T18:06:14.336536Z\", \"payload\": [ 1, 0, 237, 2, 33, 7, 14, 37, 20, 0, 15, 126, 171 ], \"eui\": \"a8-17-58-ff-fe-03-e4-66\", \"_msgid\": \"c744131e.38bbf\", \"object\": \"\" };\nmsg.payload = t;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":390,"wires":[["a9bc0f8a.e246"]]},{"id":"fff6ff25.ac453","type":"tcp out","z":"5751999a.c509a8","host":"","port":"3089","beserver":"client","base64":false,"end":false,"name":"","x":720,"y":550,"wires":[]},{"id":"a9bc0f8a.e246","type":"json","z":"5751999a.c509a8","name":"","property":"payload","action":"","pretty":false,"x":650,"y":470,"wires":[["fff6ff25.ac453"]]}]



If I do it like that then the message comes trough to my server, then we now that working fine.



Now its working :slight_smile: thanks a lot for your help !