IP address of controller not correct
Hi,
I noticed the mavesp library doesn't parse the correct IP address from the sending controller. Im using mavp2p in a Docker container which sends packets to mavesp via UDP. I have no control on that docker container in what IP address it needs to advertise. However I do not think this is a mav2p2 issue as the IP address advertised is 192.168.0.1 which is not the container IP address. It's no where used in my network.
When I set the IP fixed in the mavesp .js code, all works fine.
Do you know what causes this and perhaps enhance that function so we can set manually set the send IP.
async start(receivePort = 14550, sendPort = 14555, ip = '') {
this.sendPort = sendPort;
this.ip = ip;
// Create a UDP socket
this.socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true });
this.socket.on('message', this.processIncomingUDPData);
// Start listening on the socket
if (this.ip === '') {
return new Promise((resolve, reject) => {
this.socket?.bind(receivePort, () => {
// Wait for the first package to be returned to read the ip address
// of the controller
(0, utils_1.waitFor)(() => this.ip !== '')
.then(() => { resolve({ ip: this.ip, sendPort, receivePort }); })
.catch(e => { reject(e); });
});
});
} else {
return new Promise((resolve) => {
this.socket?.bind(receivePort, () => {
resolve({ ip: this.ip, sendPort, receivePort });
});
});
}
}
Regards, Bastiaan
Docker is a tricky thing. The IP address comes from whatever sent the first heartbeat - that's how other applications do it as well.
If it gets in your way when using docker, you can always connect those
things manually by resolving the host name (each container will advertise
its location by its name and that you can resolve to an IP manually) and
assigning the IP address in the start method.
Hope this helps!
wt., 4 lut 2025 o 10:59 Bastiaan @.***> napisał(a):
Hi,
I noticed the mavesp library doesn't parse the correct IP address from the sending controller. Im using mavp2p in a Docker container which sends packets to mavesp via UDP. I have no control on that docker container in what IP address it needs to advertise. However I do not think this is a mav2p2 issue as the IP address advertised is 192.168.0.1 which is not the container IP address. It's no where used in my network.
When I set the IP fixed in the mavesp .js code, all works fine.
Do you know what causes this and perhaps enhance that function so we can set manually set the send IP.
async start(receivePort = 14550, sendPort = 14555, ip = '') { this.sendPort = sendPort; this.ip = ip; // Create a UDP socket this.socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true }); this.socket.on('message', this.processIncomingUDPData); // Start listening on the socket if (this.ip === '') { return new Promise((resolve, reject) => { this.socket?.bind(receivePort, () => { // Wait for the first package to be returned to read the ip address // of the controller (0, utils_1.waitFor)(() => this.ip !== '') .then(() => { resolve({ ip: this.ip, sendPort, receivePort }); }) .catch(e => { reject(e); }); }); }); } else { return new Promise((resolve) => { this.socket?.bind(receivePort, () => { resolve({ ip: this.ip, sendPort, receivePort }); }); }); } }Regards, Bastiaan
— Reply to this email directly, view it on GitHub https://github.com/ArduPilot/node-mavlink/issues/42, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHICTTBOK5ASY2QNNVXP32OCFO3AVCNFSM6AAAAABWOETNYCVHI2DSMVQWIX3LMV43ASLTON2WKOZSHAZDSNRWGU2TINQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Closing as there has been no movement in this case for 6 months.