B4J Question UDP & Multiple Clients?

tchart

Well-Known Member
Licensed User
Longtime User
I have a couple of devices (Orvibo smart plugs). I have reprogrammed them to talk to my own VPS server instead of the manufacturers servers. The devices communicate over UDP all on the same port (10000).

Now, if one device is connected everything works fine and I can see the packets going back and forth.

If I connect a second device I can see the incoming packets but the second device does not receive any reply packets I send from the VPS.

Same applies for a third device etc.

Now if I set the second device to another port (eg 10001) then the second device works fine as well.

My understanding of UDP is that it handles multiple clients.

Does anyone know why the second, third, forth etc devices do not receive any packets?
 

tchart

Well-Known Member
Licensed User
Longtime User
That's not 100% correct.

Are you sending the messages to the broadcast address? Are they all connected to the same local network?

Hi Erel

All the devices are on the same network in my home with their own IP addresses. I have a fixed public IP and the devices are talking to the same VPS (hosted in America).

I can see the VPS receiving packets from all devices (all coming from my home IP address) but only the device that connects first receives any of the replies (sent to my home iP address).

Is the problem because the packets are only going to the first device?

How do I send a broadcast to my fixed public IP?

Thanks

PS I am familiar with broadcast addresses on a local network but wasnt aware this may apply to internet based UDP connections
 
Upvote 0

Aristide

Member
As Erel said, UDP is not a solution for your problem, two reasons, the first is that UDP broadcast on the extrenal network is impossible, the second reason on a local network, UDP wifi is not efficient (large loss of packets), you must repeat your UDP messages.

Use MQTT, very suitable for your problem, B4J provides a very efficient server or you can solicit free internet servers. I try on local and external network, works fine and very fast
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Thanks guys. The problem is that the device is an OEM device so I cannot change the way it communicates. All I can do is change the port and VPS IP address.

I'll just use separate ports for now.

As far as I can tell the manufacturer uses multiple servers to solve the issue.
 
Upvote 0
Top