kstzl / UrsinaNetworking

A High level api to do networking with the Ursina Engine
https://pypi.org/project/UrsinaNetworking/
MIT License
71 stars 14 forks source link

Unknown Error : Invalid load key '\x00' #11

Open Dinorigami-SLHIDE opened 8 months ago

Dinorigami-SLHIDE commented 8 months ago

Hi, The module works well globally its practical in general, but I randomly get this error, that stops the server. As far as I can see, it is a pickle error (between 0 and 30 seconds after another player joins), but I don't know how to solve it, I cannot even count how many hours I have spent to try to solve it in vain. Any help would be really appreciated... I made some research on the web but very few are linked to socket and I don't really understand how everything works... Dinorigami

CodeEzpro commented 8 months ago

Can you send me the part related to connection or the whole script if possible ? if you need deeper help i'd recomend you adding me on discord : codeezpro

Dinorigami-SLHIDE commented 8 months ago

@CodeEzpro

Can you send me the part related to connection or the whole script if possible ? if you need deeper help i'd recomend you adding me on discord : codeezpro

I basically changed nothing from the base module... I just added some @Client.events and @Server.events in the related scripts

Dinorigami-SLHIDE commented 8 months ago

So I uploaded my ursinanetworking file. ursinanetworking.txt The client connects without any problem, the game works well on solo, the client sends good information to the server and I never got an error while playing alone. The problem occurs randomly after a second player joins (between 0 seconds and a few minutes) so I can't really know what causes it. I made some investigation and after this error occurs, functions like @Client.event def foo(foo2): print(foo2) don't work anymore, the client cant send messages to the server and vice-versa. However, the server detects when a player leaves or when a new player joins. Only the Ursina functions don't work anymore but the socket server is not broken. Example : image The server prints information and stops after the error occurs but other players can still join. I tried increasing buffersize, message_length, in vain. It's hard for me to search deeper as I don't know when the error occurs.

Dinorigami-SLHIDE commented 8 months ago

I searched deeper and noticed that some messages were mixed in the same package when the server receives it. Example : That is what the server has collected in the UrsinaNetworinkDatagramsBuffer class and more precisely at "self.payload = self.buf[:self.payloadlength]" bytearray(b'\x80\x04\x95\x92\x00\x00\x00\x00\x00\x00\x00}\x94(\x8c\x07Message\x94\x8c\x08MyUpdate\x94\x8c\x07Content\x94}\x94(\x8c\x08position\x94G\xc05\xfa\xe1G\xae\x14{G\xf0\x00\x00\x00\x00\x00\x00G@\x1a\xcc\xcc\xcc\xcc\xcc\xcd\x87\x94\x8c\x07visible\x94K\x01\x8c\x02h\x00\x00\x00\x00\x00\x00\x00\x80\x04\x95T\x00\x00\x00\x00\x00\x00\x00}\x94(\x8c\x07Message\x94\x8c\x0cattackPlayer\x94\x8c\x07Conte')

The first message is cut when the \x00 series start and the second one is cut at the end. How can I solve that? Where do I need to search?

CodeEzpro commented 6 months ago

Hello,Sorry I didn't warn you but the library is fixed. If the problem persists, don't close the issue.