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

Packets gets cut off #2

Open
Mo-to opened this issue Aug 17, 2022 · 0 comments
Open

Packets gets cut off #2

Mo-to opened this issue Aug 17, 2022 · 0 comments

Comments

@Mo-to
Copy link

Mo-to commented Aug 17, 2022

If more data than PACKET_SIZE defines are received, then the following function cuts off the last package:

nostale_utils/utils.py

Lines 131 to 133 in e872596

data = await self._reader.read(self.PACKET_SIZE)
for packet in data.strip().decode(self.ENCODING).split("\r"):
await self._handle_packet(packet.split())

Inserting the following lines between line 131 and line 132 will fix this bug.

while not data.decode(self.ENCODING).endswith('\n'):
    data += await self._reader.read(1)

Explanation:
The while loop will read in 1 byte at the time until it founds a \n character aka a newline at the end off the data, which indicates the end of a packet

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

1 participant