Closed Jakob-Gliwa closed 1 year ago
I think I got it
The problem lies with the use of _webserviceNodeQueue.
The handler/node itself is used to identify the msg in the Queue.
When sending multiple messages over the same node this results in the following entries: 1: {handler1, msg1} 2:{handler1, msg2} With handler1 being the same instance.
This leads to several problems:
One solution could be to add the used uri explicitly to the queue to use it like so
LoxoneMiniserver.prototype.removeWebserviceNodeFromQueue = function (handler, uri) {
this._webserviceNodeQueue.forEach(function (node, i, outputNodes) {
if (node.handler === hanlder && node.uri === uri) {
outputNodes.splice(i, 1);
}
});
};
client.on('message_text', function (message) {
switch (message.type) {
case 'json':
data.json = _limitString(JSON.stringify(message.json), text_logger_limit);
node.log("received text message: " + data.json);
break;
case 'control':
for (let i in node._webserviceNodeQueue) {
const wsNode = node._webserviceNodeQueue[i];
const handler = wsNode.handler;
const uri = wsNode.uri;
const nodeMsg = wsNode.msg;
if (uri === 'j' + message.control) {
let msg = Object.assign(nodeMsg, {
'payload': message.value,
'topic': message.control,
'code': parseInt(message.code)
});
Thank you very very much. 0.10.13 released with your pull request. Please test.
I am sending multiple messages via the "webservice" node to my miniserver (about 150 after another). Here I stumbled over the following problem: Somehow the wrong payload and topic are set to the response from the webservice (always the one from the next message).
See the following example:
You will see that topic != uuid and that topic is somehow the uuid of the next message. The payload of message n is the wrong one. It contains the values from the control that is in the given topic, not of the control with the uuid, that had been provided in the uri.
I see the same behavior when sending multiple messages in parallel, queueing the messages and limiting the service calls to 1 call per second.
Message n
uuid: "17a05e9c-023a-15d4-****" uri: "jdev/sps/io/17a05e9c-023a-15d4-****/all" measurementname: "Bewegung Hobby" _msgid: "ba56abc1988d5eae" payload: object topic: "dev/sps/io/17a05ebc-0142-2f62-****/all" code: 200 data: object msInfo: object lastModified: "2023-01-06 00:58:12" measurementContent: object measurement: "Bewegung Hobby" _event: "node:785295cd48d3fd52"
Next message n+1
uuid: "17a05ebc-0142-2f62-****" uri: "jdev/sps/io/17a05ebc-0142-2f62-****/all" measurementname: "Bewegung Gallerie" _msgid: "ba56abc1988d5eae" payload: object topic: "dev/sps/io/17a05ef2-01c3-4a74-****/all" code: 200 data: object msInfo: object lastModified: "2023-01-06 00:58:12" measurementContent: object measurement: "Bewegung Gallerie" _event: "node:785295cd48d3fd52"
Any idea where this might be coming from?