-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message parser error #325
Comments
I think I see what's happening. If we receive a partial message, this line will return What we should do in that case is store the buffer for later when we receive the rest of the message. We could also be a bit smarter about how we handle prefix validation and scan for the prefix, like we do with the suffix. This way we continue processing messages in the event there is junk before the actual message. |
I see. There is also something up with the reconnect code. I create a device once. And operate on that device during the lifetime of the application however reconnected after a certain amount of time will fail and just through |
I think @kueblc is right, ideally we would be appending all received data to a buffer that we then can scan for packets. It's possible to get the device into a bad state by sending invalid packets / too many, which is why the re-connection sometimes doesn't work. I would recommend waiting for an ACK for your SET command before sending another; from personal experience with sending commands as continuously as possible it should work. |
Are there any upcoming planned releases ? |
If you're asking for any releases specifically addressing this issue, no. This issue can be worked around in user-land and I don't currently have enough bandwidth to do a complete overhaul of the way messages are handled. 'v6' of TuyAPI exists here, and while it's incomplete, lacking documentation, and at the moment currently parses messages the same way; that's where I would implement this. PRs are welcome. 😉 Also see: #169. |
Has anyone managed to tackle this issue? I get a @codetheweb I wonder - what does P.S.: Props for this awesome piece of RevEng! I wish I could contribute, but I'm new to this project and IoT in general, so it'll take me quite some time. |
Means you can work around the problem by accounting for it in your own code, without making changes to the library. @codetheweb recommended the following:
If you're getting this issue while attempting a new connection, then something else might be going on. If you can gather some more debugging information, open a new issue and we can take a look. |
I have the same issue as @shellcatt. Newly added Smart Bulb to Tuya Smart iOS app (works in app). I'm using Tuya Smart Device within Node-RED which makes use of this library. But it's not happy about this smart bulb when trying to connect, throws It shows up in the
But errors with the
I could post the whole (seemingly invalid) packet that's throwing the error? Or, if there's a Discord server and someone has time to debug with me that would be very appreciated? All my other tuya devices are smart dimmers, they all work fine via the api. This is my first (and only) smart bulb. Update: I unpaired and repaired in Tuya Smart iOS app to see if an updated key would help, it did not. |
Is this still relevant? |
It was never resolved for me. I bought a zigbee tuya bulb instead (using zigbee2mqtt). And gave away the problem wifi one. |
Ok, but so likely noone can proof or support with logs. So I close for now. Thank you! |
Controlling lights by increasing / decreasing brightness with a for loop over brightness levels to smooth dimming / lighting. Sometimes it works often times i get
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds at boundsError (internal/buffer.js:70:11) at Buffer.readUInt32BE (internal/buffer.js:295:5) at MessageParser.parsePacket (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:120:27) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:211:25) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) at MessageParser.parseRecursive (F:\WebProjects\javascript-playground\node_modules\tuyapi\lib\message-parser.js:218:19) { code: 'ERR_BUFFER_OUT_OF_BOUNDS' }
or
TypeError: Prefix does not match: 21497c0000aa55000055aa000000fe0000000
or
Error: Error from socket
Sometimes they can be quickly be resolved by rebooting the application, however trying to reconnect within the app using find -> device.connect() will fail until the whole app is restarted or it will continue throwing socket errors for an extended period of time when trying to reconect
The text was updated successfully, but these errors were encountered: