In my testing environment I have a USB gateway modem and a single 3 channel thermocouple node that is transmitting data to this gateway. The node-red flow I have is quite simple, the gateway data goes to a HTTP post node and a debug node. The service endpoint that HTTP goes to inserts the json into a database. No other flows are using the gateway node I have on that flow.
I was looking in the database and saw there are many instances where there are several data samples with the same received timestamp. I know this data is not all the same timestamp. The values (the temperatures) are different, the counter is different. I have included a screenshot of one of these instances where I had 6 measurements at the same timestamp when it should not have been. I have marked out the mac address, but they all have the same mac.
My question is if there are any known bugs where this is occurring.
Node-Red version 4.0.5 and ncd npm package version 1.0.9.
The timestamps are assigned when the data is ingested into Node-RED. The NCD Library executes the Date.now() method to assign the timestamp to the received property. The value returned by Date.now() is derived from the Windows system clock. Could you verify if the date on your Windows machine where Node-RED is running is correct?
It is correct and definitely not “stuck” at the same time for that length of time. The node is configured to transmit every 10 minutes so in that case Date.now() would have returned the same time for an hour. I don’t think that would be the case. Quite strange.
Hi @duelingcats That is correct, now() is a static method of the Date object, it returns the value in milliseconds representing the time elapsed since the Epoch. I will try to replicate the issue locally.
Hi @duelingcats I’ve tested locally and I’m not able to replicate the issue. Could you perform the following test? Try adding the following function node and connect it between the output of the Wireless Gateway node and the input of your HTTP node. Please also add a debug node at the output of the Date function node so we can observe the data locally. To do this, copy the attached JSON file, then go to Node-RED, click on the main menu, select the Import option, paste the code, and click on Import. Finally, connect the node (I’ve attached a screenshot as a reference).
@Eduardo_Mtz After I initially posted this thread talking about the duplicates, I restarted node-red yesterday and since then have not had any measurements with duplicate timestamps. I have tried a few things to duplicate the issue, but have not been able to. I see the node you created sets the payload received object to the current date, although that should be set already.
I would like to not include that node yet as I am still trying to find a way to duplicate the issue. As of now, I haven’t yet found a way.
Here is my flow I have that I encountered the issue. As you can see it is pretty basic and nothing really stands out why it would have duplicate timestamps. I’ll report back later if I find duplicate data again.
Hi @duelingcats Sure, yes, it is quite strange. The Function node simply allows us to verify if the Date.now() method is working correctly and returning the proper timestamp. Let me ask you, are you using a USB Modem connected to a Windows machine, or an Enterprise IIoT Gateway?
Can you check which of our libraries you have installed and which version of it? There is an older bug that duplicated serial port event emitters on older versions of ncd-red-wireless and @ncd-io/node-red-enterprise-sensors when a flow is re-deployed repeatedly.
Can you also check your configuration nodes in Node-Red to look for duplicate serial ports? Having multiple instances of a serial port can cause erratic behavior
@jacob I am using node-red-enterprise-sensors v 1.0.9. I looked for duplicate serial ports and didn’t see any. I have one for COM8, but is unused and nothing is communicating on that port. That node isn’t placed either. The other one with the name marked in red is COM3 and has the NCD gateway communicating on it. There is only 1 flow with that node and only 1 instance of that node in that flow as you saw in my screenshot earlier.
I would recommend updating the library and the issue should go away.
If you’d prefer to stick with the version you’re currently running just remember multiple deploys may duplicate the serial port data and a restart should resolve the issue.