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

Receiver is unable to find message size despite parsing correctly #79

Closed
M0n7y5 opened this issue Nov 7, 2022 · 4 comments
Closed

Receiver is unable to find message size despite parsing correctly #79

M0n7y5 opened this issue Nov 7, 2022 · 4 comments

Comments

@M0n7y5
Copy link

M0n7y5 commented Nov 7, 2022

Hi, for some reason when i send some message from my server to client, client will receive it, parse it and invoke OnReceive(myType msg) correctly. After going out of scope, it throws assert error.
obrazek

After some investigation. i found out it that it tries to get message size like this:
obrazek

offset2 is 58 in this case:
obrazek

resulted message size is 0;

This is the content of the buffer
obrazek

This is called only once:
obrazek

obrazek

For some reason it tries to invalidate this message after invoking OnReceive(myType msg) and data inside that struct are correct. So i don't quite understand the callgraph here. Here is callstack:
obrazek

@chronoxor
Copy link
Owner

First of all please check that you call Reset() for each time, you client is connected:

        void OnConnected()
        {
            // Reset FBE protocol buffers
            Reset();
            ....
        }

@chronoxor
Copy link
Owner

If you have your own Server & Client implementation, I suggest starting from ProtoServer/ProtoClient examples to get everything works fine and replace TcpServer/TcpSession/TcpClient with your own transport layer.

@M0n7y5
Copy link
Author

M0n7y5 commented Nov 7, 2022

If you have your own Server & Client implementation, I suggest starting from ProtoServer/ProtoClient examples to get everything works fine and replace TcpServer/TcpSession/TcpClient with your own transport layer.

That's what i am trying to do. But the documentation here is outdated and the fact that i need to go to completely different repository in order to get proper info about how to use this project is kinda red flag for me...
For transport i am using Asp.Net websockets with custom encryption. I tested it all before i tried to plug in FBE for some actual protocol. It works flawlessly. But now am getting confusing crashes when i am trying to use FBE;

First of all please check that you call Reset() for each time, you client is connected:

        void OnConnected()
        {
            // Reset FBE protocol buffers
            Reset();
            ....
        }

I am already doing that.

Fun fact... Setting this to 0 here makes it work without crash but it is printing this infinitely
obrazek

remedybg_Avwa9Y8MNR

So that means it correctly get message size. But still why is it able to print that message and the after printing its get validated?
Shouldn't be this other way? Invalidate message -> Parse -> Invoke handlers?

@M0n7y5
Copy link
Author

M0n7y5 commented Nov 7, 2022

I found the issue... The issue was additional message byte padding created by encryption algorithm. Since FBE tries to parse entire provided buffer. It was parsing first message correctly and then it tried to parse rest of the buffer. Since excess bytes are null, static assert with invalid message size is triggered. I made some additional changes and now it seems to be working fine.
I was under the impression that FBE will ignore those padding bytes which DOES but not in Debug mode.

@M0n7y5 M0n7y5 closed this as completed Nov 7, 2022
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