Udp Endpoint Reply

Hi,

I’m using a IoT device that report data using UDP protocol. According to it documentation, it require ACK that should be replied to it on the sending port.

Dev1 Send using IP1 PORTX
EDGE should reply to IP1 PORTX

I think that currently the communication is closed after data received. So we can’t preform a reply.

Losant does not support UDP directly to the cloud platform. The Gateway Edge Agent, however, does support UDP.

I was able to receive UDP Data from EdgeAgent, but I cant send a reply to the device.

The ACK Reply is required otherwise the device will send the same data until it receive a ACK.

I was able to do that using c# python and nodejs, but using losant I think the udp communication is disposed after receiving.

I tried to do a UDP Send using the address and port of device sender, nothing is received.

Can we run nodeJS File on a Workflow Node ?

UDP is a connectionless protocol, so there’s no concept of disposing the connection for a reply. You should be able to use the UDP: Send Node to send data to the device. I would recommend double checking the device’s port. The port you see when receiving data may not be the same port the device is listening on.

This is a fairly good thread that explains it:

As for directly hosting a NodeJS application, the recommended approach is to put the application in another Docker container and run it alongside the Edge Agent.

Yes that what I was underattended before.

Now, I did a small Scenario.

When I send a message on my nodejs app from my android phone, I got a reply from my node js server but using losant and this simple workflow, I see the message on losant debug, but the reply not comes from the losant udp sender.

I tested the losant udp sender separately to send message to an udp server, and it’s works.

So, I’m confused on what I’m doing wrong !

Thanks for the details. I’ll work with the UDP Node today and see if I discover anything.

I believe your issue is that the incoming address and port are not what you expect. Due to Docker networking, or other network factors, those may not reflect the actual address and port of the device that sent the message.

For example, here’s a successful message+ACK:

And here’s my workflow. You can see that the address and port that the device is actually listening on is very different than what the workflow received.

Can you confirm that the sourceAddress and sourcePort values match the address and port your device is listening on?

Yes I do. I used the same config with nodeJS code and Losant Workflow.

did you checked losant with this Android app ? https://play.google.com/store/apps/details?id=com.jca.udpsendreceive

I had the same result. The IP addressed received by the edge agent is not the IP address of my Android phone. On the Android app, I did have to change the Read Timeout setting because by default it was set to not listen at all.

Android app showing the ACK sent by the workflow:

The workflow:

Can you paste a screenshot confirming that working.sourceAddress and working.sourcePort are the IP address and port that your Android phone is listening on?