Skip to content
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

if ack returns after the timeout trigger ,a IllegalStateException will be thrown #964

Open
BianJianyu opened this issue Mar 8, 2024 · 8 comments

Comments

@BianJianyu
Copy link

BianJianyu commented Mar 8, 2024

version:2.0.9

  1. onTimeout() will remove ackCallback,however ackCallback is necessary while package decoding.
    file:com/corundumstudio/socketio/ack/AckManager.java line:157
image file:com/corundumstudio/socketio/protocol/PacketDecoder.java line:300 image 2. if callback is null, the byteBuf will not be read. And the the loop will run second time! file:com/corundumstudio/socketio/handler/InPacketHandler.java line:64 image 3. however the data in the buffer is already wrong, so it cannot get the right type, and then throw the IllegalStateException file:com/corundumstudio/socketio/protocol/PacketType.java line:42 image
@BianJianyu BianJianyu changed the title if ack return when timeout trigger ,a IllegalStateException will be thrown if ack return after timeout trigger ,a IllegalStateException will be thrown Mar 8, 2024
@BianJianyu BianJianyu changed the title if ack return after timeout trigger ,a IllegalStateException will be thrown if ack returns after the timeout trigger ,a IllegalStateException will be thrown Mar 8, 2024
@malinGH
Copy link

malinGH commented Mar 11, 2024

if (callback != null) {
ByteBufInputStream in = new ByteBufInputStream(frame);
AckArgs args = jsonSupport.readAckArgs(in, callback);
packet.setData(args.getArgs());
}else {
frame.clear();
}
what if I write it like this?
@mrniko
#965

@malinGH
Copy link

malinGH commented Mar 19, 2024

3A6E8155-C3B6-41e6-BD11-3EAC9929600D
E853EA39-0E46-411E-83D0-1540D3F19ADE
this is test result ,nothing exception

@mrniko
Copy link
Owner

mrniko commented Mar 22, 2024

@malinGH

What about the case then there are other packets next to this packet? they won't be parsed if bytebuf readIndex reset to zero

@mrniko
Copy link
Owner

mrniko commented Mar 22, 2024

It's better to use the code below.

frame.skipBytes(frame.readableBytes());

Now the buffer was consumed completely.

@malinGH
Copy link

malinGH commented Mar 26, 2024

let me try

@malinGH
Copy link

malinGH commented Mar 27, 2024

@mrniko Test is fail, You need to test this version, branch:master
截屏2024-03-27 15 53 23

@malinGH
Copy link

malinGH commented Mar 27, 2024

截屏2024-03-27 15 57 26

@malinGH
Copy link

malinGH commented Mar 27, 2024

6437A52C-EE5F-437a-B958-1BCE6E44AAAC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants