# RangeError: The value of "offset" is out of range. It must be \>= 0 and \<= 0. Received 1

**URL:** <https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588>\
**Category:** General\
**Created:** [10 June 2024 07:05 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588 "2024-06-10T07:05:21Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 07:05 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/1 "2024-06-10T07:05:21Z")

</div>

Could anyone please help me to resolve below error please.

 ![MicrosoftTeams-image (1)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1fe2df671e16066b3675bfe7d83853afdd4ad7a6.png)

RangeError: The value of "offset" is out of range. It must be \>= 0 and \<= 0. Received 1

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 June 2024 07:29 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/2 "2024-06-10T07:29:05Z")

</div>

Welcome to the forum @Mayur

Which node is generating the error? Click on the node id in the debug pane ant it will show you. It is a good idea to give significant nodes names so that it is easier to identify them.  
Are you using the latest versions of all nodes? Check in Manage Palette.

Also tell us which versions of node red (seen at the bottom of the dropdown menu) and which version of nodejs (in a command window run `node -v` to find out).

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 07:32 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/3 "2024-06-10T07:32:25Z")

</div>

The data going in to buffer-parser is not suitable for the settings you have in the buffer-parser node.

Export the share buffer parser (CTRL-E) so we can see what you have set

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 08:35 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/4 "2024-06-10T08:35:26Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3798775f30f8e079e03f8058622e48ab17a39df2.png)

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 08:37 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/5 "2024-06-10T08:37:48Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e87c132e94e0b697c70470fbfba1c1b46e58faa6.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 08:38 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/6 "2024-06-10T08:38:25Z")

</div>

A screenshot of the export process is not going to help I am afraid. We need the actual flow JSON it exports to be able to help.

1. Click + Select the buffer-parser nodes
2. Press `ctrl+e`
3. Click "Copy to Clipboard"
4. Paste the export into a code block in a reply

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 08:42 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/7 "2024-06-10T08:42:40Z")

</div>

```auto
[
    {
        "id": "2d2ffc8049288890",
        "type": "buffer-parser",
        "z": "129ad6e53bd2b94a",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatbe",
                "name": "item1",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 110,
        "y": 680,
        "wires": [
            [
                "170e1f1f15dbc9c5"
            ]
        ]
    }
]

```

_admin edit: wrap flow JSON in triple backtick code block_

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 08:49 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/8 "2024-06-10T08:49:36Z")

</div>

That buffer parser works with the data you showed in your first screenshot:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca855e31343a69a04880cb5956d2b40d3251b270.png)

but I doubt it is the value you expected!

Q: What is the expected value supposed to be?  
Q: What is the specification of the register you are reading? Int32? Float32? UINT16 divided by 10? etc etc

_flow for the above demo_ (use `CTRL-I` to import)

```auto
[{"id":"2d2ffc8049288890","type":"buffer-parser","z":"99e019d5.6f0748","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":750,"y":640,"wires":[["aef1dfab318f76ef"]]},{"id":"4d977988ba601fa7","type":"inject","z":"99e019d5.6f0748","name":"fake modbus data [43586,16818]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[43586,16818]","payloadType":"json","x":510,"y":640,"wires":[["2d2ffc8049288890"]]},{"id":"aef1dfab318f76ef","type":"debug","z":"99e019d5.6f0748","name":"debug 19","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":640,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 09:13 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/9 "2024-06-10T09:13:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7de1ab6647d25d36703ed42a7a0812d067d2ca48.png)

We are trying to fetch WirelessHART data via MODBUS TCP IP protocol as per below:

PAT-WVM-01.PV | 40001 | | FALSE|

Which is 32 bits (float)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 09:32 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/10 "2024-06-10T09:32:29Z")

</div>

Please answer other question

> [@Steve-Mcl](#):
>
> Q: What is the expected value supposed to be?

e.g. PAT-WVM-01.PV, Register `40001` with a data value of `[43586,16818]` should be parsed to `xx.xxx` ???

i.e. What is a realistic looking final/parsed value for this register?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 09:37 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/11 "2024-06-10T09:37:48Z")

</div>

More questions:

1. What version of NodeJS is Node-RED running on
  1. `node -v`

2. What version of Node-RED is this (see top-right hamburger menu)
3. What version of buffer-parser are you using (your screenshot does not show this)
  1. ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aaa87f759ca65ce282491aa48afe166bc9ff5291.png)

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 10:03 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/12 "2024-06-10T10:03:51Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b8ca9648431b502223d6cc82463817656f7f7f6.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/4059365ac7b873d4841015a99aeecf911e1a1093.png)

Value of PV SV TV QV shown in Gateway (As per attached image) needs to be fetch to Node Red in Debug

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [10 June 2024 10:07 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/13 "2024-06-10T10:07:29Z")

</div>

1. Node JS version: v20.13.1
2. Node Red Version: v3.02
3. ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/862c98217170662b3d6896ba4fb4a3cffdd82958.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 June 2024 10:50 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/14 "2024-06-10T10:50:35Z")

</div>

It looks like the data is little endian and byte swapped!.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e3dbf585a07f25426bf76378fbd377ace457e8d8.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/a/4afdc4f1cfcad3b6f992347a516bf6037422a4ce.png)

That is quite messy! You will need to swap all data and use the LE functions.  
_(most modbus data I have encountered is **not** byteswapped and uses the BE (Big Endian) options)_

Looking at a random manual i found, your gateway supports setting the endianess - I probably would recommend you swap at source.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7c6bdfd6bf2405e6a26df842f7d935e4d14e313.png)

  

Demo flow for the above screenshot:

```auto
[{"id":"e8532cf0f31832d9","type":"buffer-parser","z":"99e019d5.6f0748","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"float","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":750,"y":740,"wires":[["7321be9f1e43adca"]]},{"id":"7321be9f1e43adca","type":"debug","z":"99e019d5.6f0748","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":740,"wires":[]},{"id":"2ea9c23b3c030ad7","type":"inject","z":"99e019d5.6f0748","name":"fake modbus data [3612,16825]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[3612,16825]","payloadType":"json","x":510,"y":740,"wires":[["e8532cf0f31832d9"]]}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 June 2024 05:54 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/15 "2024-06-11T05:54:00Z")

</div>

I see you have started a new thread. Does that mean my previous post helped you solve this problem? If so, please mark it as a solution so that it can help future readers with the same problem.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 September 2024 05:54 UTC](https://discourse.nodered.org/t/rangeerror-the-value-of-offset-is-out-of-range-it-must-be-0-and-0-received-1/88588/16 "2024-09-09T05:54:57Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
