【问题标题】:Multicast message not received by client客户端未收到多播消息
【发布时间】:2019-10-07 00:39:19
【问题描述】:

使用 tcpdump 我在 ETH0 上看到这些多播消息:

19:50:31.493386 IP 169.254.17.110.60000 > 239.1.0.8.60000: UDP, length 273
19:50:31.493962 IP 169.254.17.110.60000 > 239.1.0.8.60000: UDP, length 153

但我没有通过客户端程序收到它们。我试过 Python 和 NodeJS:

const PORT = 60000;
const HOST = '10.100.0.1';
const MCAST = '239.1.0.8';

const dgram = require('dgram');
const client = dgram.createSocket('udp4');
client.bind({address: HOST, port: PORT}, () => {
    const address = client.address();
    console.log('UDP Client listening on ' + address.address + ":" + address.port);
    client.setBroadcast(true);
    client.setMulticastTTL(128);
    client.addMembership(MCAST, HOST);
});

client.on('message', (message, remote) => {
    console.log('From: ' + remote.address + ':' + remote.port +' - ' + message);
});

我的 ETH0 IP 是 10.100.0.1。我尝试不绑定到我的主机没有成功。

如果我将带有另一个 NodeJS 脚本的多播消息发送到相同的地址和端口 (239.1.0.8:60000),我的客户端程序会收到该消息。

我正在开发 Debian Stretch:

Linux car 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux

感谢您对此的任何指导。

【问题讨论】:

    标签: node.js linux udp multicast tcpdump


    【解决方案1】:

    尝试用

    捕捉错误
    client.on('error', (err) => {
      console.error(err);
    });
    
    

    【讨论】:

    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2020-02-01
    • 2012-06-04
    • 2020-05-13
    • 2015-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多