-
Notifications
You must be signed in to change notification settings - Fork 408
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
[Bug]: Modbus RTU over TCP read fail in loop #1443
Comments
I was able to reproduce this error using a linux vm and connecting to that ... will investigate. |
Yes, the test program and modas simulator were launched on Linux 6.1.71-1-MANJARO |
Ok ... so running the example program produces this output in wireshark: |
Ok ... progress ... So if I output the size of a message in the buffer in side ByteLengthEstimator I can see all successful read responses for request 1 are 255 bytes large, in message 20 for some reason only 240 bytes make it into the buffer and the byte-length estimator therefore keeps on reporting "-1" (Not enough). However the missing bytes don't seem to be added. |
Ok .. mainly leaving this info here for myself if I don't finish it today:
So for some reason the buffer is shrinking and starting with the 20th iteration of your program, the amount of available buffer space becomes less than the packet needs to be parsed and that's when things go south. I need to find out why the buffer is not freed. |
Ok ... so it turns out that in the failure case, the ByteLengthEstimator didn't throw a ParseException but an ArrayIndexOutOfBoundsException, so I added a handler for that, that also manually calls compaction of the netty buffers. This now made the application iterate through all 45 rounds. Even updating that to run 450 times caused no issues. Please try try if my changes resolved your issues. |
I checked your fix on several similar examples. I didn't see any problems. Thank you! |
What happened?
Error decoding TCP package after N read requests.
Example code causing the bug
Description
-m enc
modbus-tcp
modeCode
Output log
Full log file
Version
v0.12.0
Programming Languages
Protocols
The text was updated successfully, but these errors were encountered: