aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/broadcast/MulticastBroadcastService.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
index 134bba797..c4ba0e059 100644
--- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
+++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java
@@ -161,17 +161,17 @@ public class MulticastBroadcastService implements BroadcastService {
@Override
public void run() {
try (MulticastSocket socket = new MulticastSocket(port)) {
- publisherSocket = socket;
+ socket.setNetworkInterface(networkInterface);
socket.joinGroup(group, networkInterface);
+ publisherSocket = socket;
while (!service.isShutdown()) {
DatagramPacket packet = new DatagramPacket(receiverBuffer, receiverBuffer.length);
socket.receive(packet);
String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8);
- LOGGER.info("Broadcast received: {}", data);
handleMessage(objectMapper.readValue(data, BroadcastMessage.class));
}
- socket.leaveGroup(group, networkInterface);
publisherSocket = null;
+ socket.leaveGroup(group, networkInterface);
} catch (IOException e) {
throw new RuntimeException(e);
}