-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Websockets, Inflate: deflatedBytes is not empty when inflate is called in MessageInflater. ("java.lang.IllegalArgumentException: Failed requirement." Exception) #8551
Comments
cc @swankjesse I wonder whether it's triggering the codepath changed in #8078 ? We avoid infinite loop, but leave bytes in the buffer? |
@yschimke I just want to add that we have been using the version with the fix successfully for some time. Just one litte change in the provided payload and the package works. We must be running into some edge case here. |
I can't reproduce this exception, even if there are additional bytes left in a completed inflation, it's the inflater is either still finished, or reset. I tried with https://github.com/yschimke/okhttp/pull/new/test_inflator without luck I'm probably doing something wrong and unfamiliar with the code, but I can't inflate that input either.
Are you able to provide a reproduction? I guess specifically on Android? |
Hi @yschimke, sorry for the late reply. I will try to respond right away in the future. I want to reiterate that the package provided is the direct package used by the server, not yet the deflated one. So to reproduce in an integration test we would need to put that package to a server that supports per message deflate. I will try to extract the deflated package and provide this as well. Yes Android is correct. |
We can recover from this and it seems like the least worst of our options. Closes: #8551
When using binary data over WebSockets we trigger the require statement in the inflate method of the MessageInflater. This happens with release 5.0.0-alpha.12 and 5.0.0.alpha.14. We are using OKhttp on Android.
This only seems to happen with a certain Package size and composition. We attached the packet we used to replicate this a 100% of the time. This is the package before it is being deflated. We can reproduce this issue with multiple server setups. If we return the package below on a server that understands per message deflate we will get the Exception every time:
bytestream.txt
The failure is always that the inflate method is called but deflatedBytes.size is > 0. Since it is a require call that it must be 0 we fail here.
We assume that the actual issue is on the inflate before the actual failure as this is apparently "finished" while still leaving 4 bytes in the stream.
The last inflate call in
WebSocketReader
before we trigger the require conditionBefore the last
readOrInflate
call before we trigger the require condition.In the last call of
readOrInflateBefore
we trigger the require condition.The end of the last inflate call before we trigger the require condition. Note that deflatedBytes size is 4 here which is the size we will trigger the require condition with.
We haven not been able to pin down the why this happens exactly, but we can we can reproduce this a 100% of the time so we can easily provide further information if needed.
The text was updated successfully, but these errors were encountered: