B4J Question Ethernet vs Wifi

Blueforcer

Well-Known Member
Licensed User
Longtime User
I try to send an SSDP Broadcast to my network.
The following Code doesnt work in B4J (get no response) But it will be send (according to WireShark). My PC is connected to the same Network via EthernetCable.
In B4A (of course wiFi) it works like a charm. Is there any known Problem to send such a broadcast message through Ethernet instead of WiFi? The devices wich should respond are also WiFi devices.


B4X:
Public Sub Search
    udp1.Initialize("UDP1", 1982, 1000)
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append("M-SEARCH * HTTP/1.1").Append(Chr(13) & Chr(10))
    sb.Append("HOST: 239.255.255.250:1982").Append(Chr(13) & Chr(10))
    sb.Append("MAN: " & Chr(34) & "ssdp:discover" & Chr(34)).Append(Chr(13) & Chr(10))
    sb.Append("ST: wifi_bulb").Append(Chr(13) & Chr(10))
    Dim package As UDPPacket
    package.Initialize(sb.ToString.GetBytes("UTF8"),"239.255.255.250",1982)
    udp1.Send(package)
End Sub

Sub UDP1_PacketArrived (Packet As UDPPacket)
    Log(Packet.toString)
End Sub
 
Last edited:

Blueforcer

Well-Known Member
Licensed User
Longtime User
That's exactly what I thought, but I can't explain this behaviour.

udp1.GetBroadcastAddress gives
"192.168.178.255"
and thats correct.
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
No, according to Yeelight Specs:
Different from SSDP protocol, we choose to send multicast messages to port 1982 instead of standard SSDP port 1900. This is to avoid excessive multi-cast messages being received by both smart LED and 3rdparty devices. It's especially important if the 3rd party device is power-consumption-sensitive (e.g. smart watch powered by battery).

anyway, it works over WiFi but not over Ethernet.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
When you are on WiFi, are all the devices you reach also on WiFi? Do both WiFi and Ethernet have the same network? Could it be possible that your router blocks broadcasting from Ethernet to WiFi and/or vice versa?
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Yeah sure, i also can control the wifi devices with TCP.

A friend said that there is no one who forward a broadcasts message, so an ethernet broadcast can only go to Ethernet devices. Same with Wifi
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
And thats the problem, my router does not have such a setting. if I use an WifiStick on my PC it also works in B4J.
So i search the devices via nmap now. not what i want, but it works.
So for all Others:
Its not possible to send a Broadcast from an ethernet device to wifi devices out of the box. The client will never recieve it.
Wifi to Wifi works
 
Upvote 0
Top