You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a simple test harness (client.exe and server.exe) using the CPP interface and I only see one copy of a message (sent in over bus protocol). However with this JS package I am getting two copies of each message sent (cpp -> JS node program).
Node Version: 10.9.0
nanomsg: 4.0.2
This means that I get two calls to the receive() callback for each packet that arrives.
Here is my nanomsg receiver
const nano = require('nanomsg')
const { Topics } = require('./Payloads/Packet')
class LMB {
constructor(config) {
this.sock
this.config = config
this.nodeName = config.nodeName
this.topicList = config.topicList
this.topics = Topics
}
connect() {
this.sock = nano.socket('bus')
this.sock.bind(this.config.urlList[0])
this.sock.connect(this.config.urlList[1])
this.sock.on('data', this.receive.bind(this))
}
send(topic, payload) {
let size = payload.length
let packet = new ArrayBuffer(size + 8)
let buffer = new Uint8Array(packet)
let view = new DataView(packet)
view.setUint32(0, topic, true)
view.setUint32(4, size, true)
buffer.set(payload, 8)
this.sock.send(buffer)
}
receive(packet) {
let view = new DataView(packet.buffer)
let topic = view.getUint32(0, true)
let size = view.getUint32(4, true)
let payload = packet.slice(8, packet.length - 1)
global.Dispatcher.process(topic, size, payload)
}
}
module.exports = { LMB }
and here is the config that it uses, and the two copies of the start message that appear. I confirmed with the VSCODE debugger via breakpoints and the receive() method is being called twice for each arrival of a packet over the network.
It was suggested that I should not be doing both a bind(local) and connect(remote) and that that might be causing two connections to be made. But I am finding that I need both for there to be traffic,.
currently:
local = tcp://127.0.0.1:2019
remote = tcp://127.0.0.1:2018
This is very odd. I have a C++ program using nng Nanomsg (wire protocol is identical to nanomsg).
https://github.com/nanomsg/nng
I have a simple test harness (client.exe and server.exe) using the CPP interface and I only see one copy of a message (sent in over bus protocol). However with this JS package I am getting two copies of each message sent (cpp -> JS node program).
Node Version: 10.9.0
nanomsg: 4.0.2
This means that I get two calls to the receive() callback for each packet that arrives.
Here is my nanomsg receiver
and here is the config that it uses, and the two copies of the start message that appear. I confirmed with the VSCODE debugger via breakpoints and the receive() method is being called twice for each arrival of a packet over the network.
The text was updated successfully, but these errors were encountered: