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

BIG ENDIAN Error in netty with protobuf [proto: PushRequest: illegal tag 0 (wire type 0)] #134

Open
ulle1 opened this issue Dec 17, 2024 · 4 comments

Comments

@ulle1
Copy link

ulle1 commented Dec 17, 2024

First of all, cool work!

I was able to successfully connect my application to Loki on Windows. I want to run it on Unix on a ‘more specialised hardware’. I get the following message in STDOUT.log:
proto: PushRequest: illegal tag 0 (wire type 0)
I think it has something to do with the protocol buffer and Netty. Unfortunately, I can't get any further and would be grateful for any help.
I've had problems with this hardware before regarding little endian/big endian.
I would be grateful for any advice!

@ulle1
Copy link
Author

ulle1 commented Dec 18, 2024

So I found out that my Windows instance runs under ‘LITTLE ENDIAN’ and my Unix instance under ‘BIG ENDIAN’ and that I get a 400 Bad Request error from the LOKI API.

RequestAndResponseHandler.channelRead | NO SUCCESS
FullHttpResponse = {"code":400,"codeAsText":{"value":[52,48,48],"offset":0,"length":3,"hash":0},"codeClass":"CLIENT_ERROR","reasonPhrase":"Bad Request","bytes":[52,48,48,32,66,97,100,32,82,101,113,117,101,115,116]}
Msg content =
proto: PushRequest: illegal tag 0 (wire type 0)

@ulle1 ulle1 changed the title Windows config fine / Unix special device: STDOUT.log proto: PushRequest: illegal tag 0 (wire type 0) BIG ENDIAN Error in netty with protobuf [proto: PushRequest: illegal tag 0 (wire type 0)] Dec 18, 2024
@tkowalcz
Copy link
Owner

Hi. Thanks for reporting the issue. For performance I wrote the profobuf code from scratch, it is very much possible it might contain bugs with regards to endianess. I'll try to dig into this issue.

@ulle1
Copy link
Author

ulle1 commented Dec 18, 2024

Hi!

Thank you very much!
Another difference is the default charset. On Windows UTF-8, on the Unix system ISO-8859-1.

I added a System.out.println to the method in class ‘RequestAndResponseHandler’ in method ‘public void write(ChannelHandlerContext ctx, Object object, ChannelPromise promise) throws Exception’ to see the differences:

        `// create new byte buffer`
        `ByteBuffer byteBuffer = ByteBuffer.allocate(payloadSize);`

        `// copy netty byte buffer to java byte buffer`
        `FullHttpRequest fhr = (FullHttpRequest) object;`
        `ByteBuf buffer = fhr.content();`
        `ByteBuf duplicatedBuffer = buffer.duplicate();`
        `duplicatedBuffer.readBytes(byteBuffer);`

        `// output byte buffer`
        `byte[] bytes = byteBuffer.array();`
        `String s = new String(bytes);`
        `System.out.println(s);`

I made two screenshots. The dark background is from the Linux system. The white background is from the Windows system.
Screenshot 2024-12-18 112415
Screenshot 2024-12-18 112452

Perhaps this will help... It could also be a problem with the default character set encoding!?

@tkowalcz
Copy link
Owner

If you are able to modify the code can you please print the contents of the message sent to Loki? You can use io.netty.buffer.ByteBufUtil.prettyHexDump and place it in e.g. NettyHttpClient line 59 to print the dataBuffer.

Thanks!

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

2 participants