-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Batch requests over WebSocketService are overwritten by simple requests if send at about the same time #2127
Labels
bug
A bug in behaviour or functionality
Comments
Shohou
pushed a commit
to Shohou/web3j
that referenced
this issue
Dec 16, 2024
…ch ids, take the one used for requests
3 tasks
Shohou
pushed a commit
to Shohou/web3j
that referenced
this issue
Dec 16, 2024
…ch ids, take the one used for requests
Shohou
pushed a commit
to Shohou/web3j
that referenced
this issue
Dec 17, 2024
…tch ids, take the one used for requests Signed-off-by: Dmitry Shohov <[email protected]>
Shohou
added a commit
to Shohou/web3j
that referenced
this issue
Dec 17, 2024
…tch ids, take the one used for requests Signed-off-by: Dmitry Shohov <[email protected]>
Shohou
added a commit
to Shohou/web3j
that referenced
this issue
Dec 18, 2024
…ch ids, take the one used for requests Signed-off-by: Dmitry Shohov <[email protected]>
NickSneo
pushed a commit
that referenced
this issue
Jan 27, 2025
…one used for requests (#2128) Signed-off-by: Dmitry Shohov <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Request ids generated for batch requests clash with request ids of normal standalone requests
WebSocketService
insendBatchAsync
method overwritesid
of first request in batch and puts it intrequestForId
map. Problem is the new id is generated usingAtomicInteger
callednextBatchId
which is different thanAtomicInteger
used for id generation inRequest
. So what happens:Web3j.ethBlockNumber()
for example. It generatesid
usingAtomicInteger nextId
field inRequest
which starts with 0.WebSocketService.sendAsync
saves this id inrequestForId
map for further mapping of arriving response.Web3j.newBatch
adds some requests in it and sends it.WebSocketService.sendBatchAsync
generates substitute id usingAtomicInteger nextBatchId
which also starts with 0 and puts it in the samerequestForId
map overwriting first request which was there.onWebSocketMessage
method and fails with ClassCastException because it expects to find thereWebSocketRequest
by id 0, but instead getsWebSocketRequests
.WebSocketService.getAndRemoveRequest
throws IOException with message "Received reply for unexpected request id: 0"Steps To Reproduce
Steps described in description.
Expected behavior
I expect it not to fail with exceptions and responses mapped correctly with corresponding requests
Actual behavior
Two exceptions are thrown, and both requests are never completed, not even by timeout
Environment
Additional context
Exceptions:
The text was updated successfully, but these errors were encountered: