GNet error

Started by William, August 15, 2023, 00:12:11

Previous topic - Next topic

William

~>Unhandled Exception:GNet error
~>
tb
~>StackTrace{
~>@/home/william/Documents/GitHub/MedievalDreams.io/Server.bmx<27,0>
~>Function Server
~>Global Host:TGNetHost=$00007f5d18ce2fa0
~>Global listen:Int=1
~>Local shutdown:Int=0
~>@/home/william/Documents/GitHub/MedievalDreams.io/Server.bmx<25,0>
~>Local <local>
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<835,0>
~>Function GNetSync
~>Local host:TGNetHost=$00007f5d18ce2fa0
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<539,0>
~>Function Sync
~>Local Self:TGNetHost=$00007f5d18ce2fa0
~>Local succ:TLink=Null
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<482,0>
~>Local <local>
~>Local ev:ENetEvent=$00007f5d18cd9680
~>Local peer:TGNetPeer=$00007f5d18ce1dc0
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<485,0>
~>Local <local>
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<497,0>
~>Local <local>
~>@/home/william/Desktop/BlitzMax/mod/brl.mod/gnet.mod/gnet.bmx<536,0>
~>Local <local>
~>}
Happens randomly after server has been running for some time, i do not know if it is the client causing server errors or what.

any insight into this?
I'm just a mentally ill person stuck in person. I've had quite an online history and of media such as role plays with people that became movies (for real) among other things and content. I wanted to be an online famous person at one time. Unfortunately it's ill and I'm anonymous.

William

it has also happened when my computer shut down unexpectedly and the gnetobjects were not closed though i do not know whether it caused the same error
I'm just a mentally ill person stuck in person. I've had quite an online history and of media such as role plays with people that became movies (for real) among other things and content. I wanted to be an online famous person at one time. Unfortunately it's ill and I'm anonymous.

Derron

#2
As you see it fails in Gnet's TGNetHost "Sync()" command.

The error happens there, if the received event is not one of the defined three (or eg the peer is no longer existing):

Method Sync()
...
Select ev.event()
Case ENET_EVENT_TYPE_CONNECT
Assert Not peer Else "GNet error"
...
Case ENET_EVENT_TYPE_DISCONNECT
...
Case ENET_EVENT_TYPE_RECEIVE
Assert peer Else "GNet error"
...
Default
Throw "GNet error"


So as soon as the TGNetHost-instance's ".peer" is null it will error out on "connect" or "receive". And if the event is different to connect, dicsconnect or receive it errors out too.

I guess  if you adjust the error messages (to "tell more" - like:
Case ENET_EVENT_TYPE_RECEIVE
Assert peer Else "GNet error. Invalid peer in ENET_EVENT_TYPE_RECEIVE event"

You will see this message being printed.

Why?

"peer" is set there:
Local peer:TGNetPeer
For Local t:TGNetPeer=EachIn _peers
If t._enetPeer=ev.peer()
peer=t
Exit
EndIf
Next

So it assigns the peer it has inside of its _peers-list. And if it receives an event of a peer which is no longer listed ... it will error out.

Peers are only removed from the peers list on the event ENET_EVENT_TYPE_DISCONNECT.
There seems to be also "ENET_EVENT_TYPE_DISCONNECT_TIMEOUT"

I am not sure if "gnet" should listen to this enet-event too - according to the docs it:
        /** a peer is disconnected because the host didn't receive the acknowledgment
         * packet within certain maximum time out. The reason could be because of bad
         * network connection or  host crashed.
         */
        ENET_EVENT_TYPE_DISCONNECT_TIMEOUT = 4,


Things can easily be simulated when connecting from within a VM and "pausing" it (or removing the network connection in a different way). Or maybe by "forcefully exiting" the client application (so it does not gracefully disconnect).



----
I raised an issue for the stuff I found odd during my short code research now:
https://github.com/bmx-ng/brl.mod/issues/291

I am as said not a gnet user and did not read the code you are using (Midimaster's example code etc) so am not sure if there are things done wrong or incorrect.
It would be good to have some simple code (not using Midimasters helper functions) just utilizing brl.gnet and leading to the issue.
I guess you should have server and client kind of "spam" messages so a lot of messages are flying around. And then you forcefully exit a client (or the server) and check if the other sides handle it gracefully  (not just crashing/erroring out).

bye
Ron

William

ty ron. @Derron will they'll be fixes for this in the next weekly release? i dont believe there are anything i can do, i only know basic.
I'm just a mentally ill person stuck in person. I've had quite an online history and of media such as role plays with people that became movies (for real) among other things and content. I wanted to be an online famous person at one time. Unfortunately it's ill and I'm anonymous.

Derron

The stuff I changed will be in in the next weekly release. yes.


bye
Ron