Happy0 opened a new pull request #27: Fix bug with scuttlebutt boxstream 
segments not being formed properly
URL: https://github.com/apache/incubator-tuweni/pull/27
 
 
   I encountered a bug whereby RPC messages with a large body length (for 
example 20kb) resulted in the server closing the connection immediately. In the 
application I'm building with this library, there is a custom RPC handler which 
can accept large messages as parameters.
   
   I've narrowed this down to being an issue with the `slice` method on `Bytes` 
in the `encrypt` method of `SecureScuttlebuttStream`. It would appear that the 
`.size()` method retains the size of the original array that backs the slice, 
despite the `offset` and `end` that are set. This means that body length is set 
wrong in the box-stream headers, and I'm assuming the server closes the 
connection because it reads garbage rather than a header when it starts reading 
from the end of the length.
   
   You can reproduce this error by:
   
   * Copy the new `postMessageThatIsTooLong` test from this pull request to 
your local version of master.
   * Run the test
   * Observe that the connection is reset by the peer (server.)
   
   If you step through debug the test in your IDE and set a breakpoint in the 
`encryptMessage` you'll notice that the encryptedBody is longer than 4096 
bytes, and the `size` call returns more than `4096` too (for the second 
iteration around the loop.)
   
   When this same test is ran with the new `encrypt` implementation, the server 
returns a 'message too long' error response for the `publish` RPC call and the 
connection remains open (as expected for the `publish` method which has a 
maximum message length limit.)
   
   I'm hoping that you can help me fix the underlying cause with the `slice` 
method for the `Bytes` implementation(s) etc since you're more familiar with 
that module. 
   
   The implementation in this pull request is probably less efficient but it 
works as a workaround for now.
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to