# Trying to post a LoRa message to my server

**URL:** <https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020>\
**Category:** General\
**Created:** [15 February 2019 16:54 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020 "2019-02-15T16:54:29Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [15 February 2019 16:54 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/1 "2019-02-15T16:54:30Z")

</div>

Hi  
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!

 ![nodered1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7888cfb37613e35e2dd51831fdfe5e0a938b0730.jpeg)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [15 February 2019 17:08 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/2 "2019-02-15T17:08:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 February 2019 17:10 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/3 "2019-02-15T17:10:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [15 February 2019 18:15 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/4 "2019-02-15T18:15:14Z")

</div>

> [@krambriw](#):
>
> tp is the correct way? Have you tried with a tcp 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

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [15 February 2019 18:17 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/5 "2019-02-15T18:17:38Z")

</div>

This is how I configured the HTTP node.

 ![nodered2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/718e1ee801a8158be97a48c71b3ad02994addf00.jpeg)

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [15 February 2019 18:21 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/6 "2019-02-15T18:21:21Z")

</div>

> [@ukmoose](#):
>
> d the http-request node

 ![nodered3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a474c00342449c488665aed7ebbc8a5109718b4f.jpeg)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 February 2019 20:04 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/7 "2019-02-15T20:04:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [15 February 2019 20:35 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/8 "2019-02-15T20:35:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 February 2019 20:49 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/9 "2019-02-15T20:49:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [16 February 2019 08:06 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/10 "2019-02-16T08:06:07Z")

</div>

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..

 ![nodered4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3260b0dc742eec8cf4cebbe1bc4a29d743f008df.jpeg)

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [16 February 2019 08:15 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/11 "2019-02-16T08:15:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 February 2019 08:19 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/12 "2019-02-16T08:19:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [16 February 2019 11:43 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/13 "2019-02-16T11:43:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [16 February 2019 14:47 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/14 "2019-02-16T14:47:34Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fdc0db57038e3080d259beb45c96a684708cade6.png)

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [17 February 2019 18:08 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/15 "2019-02-17T18:08:48Z")

</div>

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 ☹ 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": "" }

 ![lora100](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f28fdd8beb6c47e2f268f2efa2dd4d5234222959.jpeg)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [17 February 2019 18:22 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/16 "2019-02-17T18:22:15Z")

</div>

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?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/443d558a8229a6b6af3603de036ac416df6afaea.png)

`[{"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":"213.115.224.138","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"]]}]`

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [17 February 2019 19:29 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/17 "2019-02-17T19:29:15Z")

</div>

> [@krambriw](#):
>
> [{"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":"213.115.224.138","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.

 ![lora101](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a60414c6fc4a5fa3574ef1c23118bc66f5614300.jpeg)

---

<div class="post-metadata">

**Author:** ![hjojohan](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@hjojohan](https://discourse.nodered.org/u/hjojohan)\
**Post date:** [17 February 2019 20:29 UTC](https://discourse.nodered.org/t/trying-to-post-a-lora-message-to-my-server/8020/18 "2019-02-17T20:29:28Z")

</div>

Now its working 🙂 thanks a lot for your help !

 ![nodered1001](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fb0b4e4cc6bb0cc4754a1c8c5126e3efea44bacf.png)
