MQTT from TTN to traccar server - ECONNRESET error

Hi,

I have two mqtt-in nodes pulling data from thethingsnetwork and sending it to a Traccar server:

These two nodes pulling from two different applications with different API-keys.
One of these nodes always gives me a ECONNRESET error. When I deactivate one of these nodes it is working without any error.
Can you give me a hint how I can research that issue any further?

duffy6

0b604d42fb924ba5f2b2bf514d244e4eb4523c1d

ECONNRESET error is most probably a Proxy/Firewall closing the connection on your HTTP request, not the TTN network.

Why are you using to different MQTT connections to TTN? (If I may ask)

Of course you may ask - especially because I thought about it, too.

It’s a demo traccar server (demo3.traccar.org) and for my TWO GPS-sensors dragino LGT92 I need TWO application. Or am I wrong?

This is what I have done for each of the two sensors:
New mqtt-broker
→ server config: choose name
server: „eu1.cloud.thethings.network“, Port 8883; activate SSL/TLS.

new TLS-configuration → new name
server-name: eu1.cloud.thethings.network“
download root-certificate (ISRG Root X1 from Let’s Encrypt in new config „CAcertificat“: https://letsencrypt.org/certs/isrgrootx1.pem

tls-config->security: username: TTN-application-ID@ttn“, e.g. „my_application@ttn“.
password is the API-key, for which you have to generate a API-key in TTN web-GUI „Add API key“ (Grant all rights)

Topic: „v3/application-ID@ttn/devices/Device-ID/up“; e.g.: „v3/my_application@ttn/devices/my_end_device/up“
You find the end-device-name in TTN web-GUI.

This is my node (just add your own mqtt-in node):

[{"id":"fc6935c2.3c799","type":"json","z":"2e14c1fa.166356","name":"","property":"payload","action":"","pretty":false,"x":174,"y":569,"wires":[["f9a67820.19d028","3b5803d7.3a5f44"]]},{"id":"f9a67820.19d028","type":"change","z":"2e14c1fa.166356","name":"URL (beachte Klein und Grossschreibing bei Longitude und Latitude)","rules":[{"t":"set","p":"url","pt":"msg","to":"http://demo3.traccar.org:5055/?id=TRACKERID&lat=BREITENGRAD&lon=LAENGENGRAD&timestamp=ZEITSTEMPEL&gateway=BASISSTATION&rssi=SIGNALSTAERKE","tot":"str"},{"t":"change","p":"url","pt":"msg","from":"TRACKERID","fromt":"str","to":"payload.end_device_ids.device_id","tot":"msg"},{"t":"change","p":"url","pt":"msg","from":"BREITENGRAD","fromt":"str","to":"payload.uplink_message.decoded_payload.Latitude","tot":"msg"},{"t":"change","p":"url","pt":"msg","from":"LAENGENGRAD","fromt":"str","to":"payload.uplink_message.decoded_payload.Longitude","tot":"msg"},{"t":"change","p":"url","pt":"msg","from":"ZEITSTEMPEL","fromt":"str","to":"payload.received_at","tot":"msg"},{"t":"change","p":"url","pt":"msg","from":"BASISSTATION","fromt":"str","to":"payload.uplink_message.rx_metadata[0].gateway_ids.gateway_id","tot":"msg"},{"t":"change","p":"url","pt":"msg","from":"SIGNALSTAERKE","fromt":"str","to":"payload.uplink_message.rx_metadata[0].rssi","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":602,"y":583,"wires":[["9be7bcbe.6cb7f8","99c1a069.7726e"]]},{"id":"9be7bcbe.6cb7f8","type":"http request","z":"2e14c1fa.166356","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","persist":false,"authType":"","x":1021,"y":599,"wires":[["4b90af36.2d516"]]}]

Do you see any error?

Yup, that’s a complication. Generally an application is many of the same devices for a group / site / client - which means the application can have one payload formatter and you know what it’s deployment is for.

Then you need just one MQTT for the application - the payload will tell you what the device id is so you can process the data as you need.

Both trackers can be on the same application, you can specify a decoder per node.

In the Console - Application - End Device - Select specific end device - Payload Formatters - here you can configure the decoder per device.

Now you can use one MQTT connection, then you flow will only have one flow and one HTTP post. It is trackcar not liking your double HTTP post connection.

PS. Just make sure the JSON the decoder sends look the same (msg.payload.uplink_message.decoded_payload.Latitude - msg.ayload.uplink_message.decoded_payload.Longitude ect)

Also set your MQTT node in node-red, then you can eliminate the JSON node.
image

You can, but you shouldn’t and there’s no need - you should use the repository decoder as it has the least impact on the TTN servers.

If you have two identical devices, having two copies of a PF in Redis just for your application will lead one day to TTN server meltdown.

Even having one copy for your application will contribute to the rot.

Sorry I miss read, thought it were two different manufactures for the trackers, you only need one decoder (rather use the repository decoder), one application, one MQTT integration.

“Fukushima”

1 Like

Thanks guys, I will move my trackers to ONE application.
Probably by deleting one of them and create again in the same application as the other.
1.) So there is no “move” function I guess?

2.) I do not really understand how the MQTT-in node knows which data is from which sensor?

That’s the decoder from dragino I use, copied from https://www.dragino.com/downloads/downloads/LGT_92/Decoder/LGT92-v1.6.4_decoder_TTN.txt

function Decoder(bytes, port) {

// Decode an uplink message from a buffer

// (array) of bytes to an object of fields.



var latitude;//gps latitude,units: °

  latitude=(bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3])/1000000;//gps latitude,units: °



var longitude;

  longitude=(bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7])/1000000;//gps longitude,units: °



var alarm=(bytes[8] & 0x40)?"TRUE":"FALSE";//Alarm status





var batV=(((bytes[8] & 0x3f) <<8) | bytes[9])/1000;//Battery,units:V



if((bytes[10] & 0xC0)==0x40)

{

  var motion_mode="Move";

}

else if((bytes[10] & 0xC0) ==0x80)

{

  motion_mode="Collide";

}

else if((bytes[10] & 0xC0) ==0xC0)

{

  motion_mode="User";

}

else

{

  motion_mode="Disable";

}                                            //mode of motion



var led_updown=(bytes[10] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink



var Firmware = 160+(bytes[10] & 0x1f);  // Firmware version; 5 bits 





var roll=(bytes[11]<<24>>16 | bytes[12])/100;//roll,units: °





var pitch=(bytes[13]<<24>>16 | bytes[14])/100; //pitch,units: °



var hdop = 0;

if(bytes[15] > 0)

{

   hdop =bytes[15]/100; //hdop,units: °

}

else

{

   hdop =bytes[15];

}



var altitude =(bytes[16]<<24>>16 | bytes[17]) / 100; //Altitude,units: °



return {

Latitude: latitude,

Longitude: longitude,

Roll: roll,

Pitch:pitch,

BatV:batV,

ALARM_status:alarm,

MD:motion_mode,

LON:led_updown,

FW:Firmware,

HDOP:hdop,

Altitude:altitude,

};

}

No

That’s a v2 decoder, which are supported in v3, but as above, preferable to use the repository decoder by registering a device using the “from the repository” option.

1 Like

It is not MQTT knowing, the change node you are using is the telling factor for trackcar what sensor / tracker it is — TRACKERID = msg.payload.end_device_ids.device_id

1 Like

You might have a look at this LGT92 Decoder Issue . Several decoders and a guide how to install.

1 Like

I did as I was told by you :slight_smile:

I deleted all end-devices, deleted the application.
Created a new application, created 3 LGT92 end-devices (TTN pre-defined, NOT manually).

Then I modified the mqtt-in node (new user name, new application name) and chose the topic:
“v3/application-ID@ttn/devices”

(not the topic “v3/application-ID@ttn/devices/Device-ID/up” because I want to receive ALL the end-devices).

BUT when I use the shorter topic (“v3application-ID@ttn/devices”) I do not get ANY mqtt-messages.
When I use the longer end-device-specific topic “v3/application-ID@ttn/devices/Device-ID/up” I get messages. But (back to the original problem) I want to get messages from ALL devices.

Am I doing anything wrong?

ttn

You can use the topic v3/+/devices/+/up, it will catch all “up” the messages from all devise with the application.

1 Like

Google will fill in the details of the wildcards, but you need to have:

v3/application-ID@ttn/devices/+/up

Which says use a wildcard for the device id.

1 Like