Net library buggy?

i made a simple code:

client:

hook.Add("InitPostEntity", "init_isready", function()
	local info = {}

	info.iswindows = system.IsWindows()
	info.islinux = system.IsLinux()
	info.isosx = system.IsOSX()
	info.country = system.GetCountry()

	net.Start("ply_is_ready")
		net.WriteTable( info )
	net.SendToServer()
end)

server:

util.AddNetworkString("ply_is_ready")
net.Receive("ply_is_ready", function( len, ply )
	local tab = net.ReadTable()

	ReceivedReadyMessage( ply, tab )
end)

but for some clients (10% or such) it is never received by the server
it is called clientside but never reached the server

i also tried looping the message
so it send it every 4 seconds till its received
but it still dont reached the server

any ideas?

or is it a bug?

1 Like

Please never send Tables from client to server unless you know what you are doing, this can be used to crash the server.

After testing (actually i just retry’d multiple times with the same code you have and it worked on my server without issues (even with high paket loss)

so either its because you could have a lot of players (net channel overflow on your server just by too many clients sending too much stuff at the same time, can be fixed by removing or optimising addons)

or you have something like gProtect that could block some messages like these (which may not fit the affected player range)

i would recommend checking your networking by for example adding some debugger (i guess gprotect has one? idk)
(depending on the debugger either a lot of data can be produced (logs) or a lot of performance can be lost)
to see if there is something that could be optimised.

2 Likes

thanks for the info, will test it out!

the problem is still happening for some players (i tried without tables and tried without any data)
(no net message was received to the server)

i debugged (printed) that the net.start + net.sendtoserver happening in the code (clientside)
but the server never got the message… really strange (no prints there)

maybe its because of a “beta” branch?
is it possible to get the “beta” branch via lua?

1 Like

thx!

the clients that have the problem, dont have it all the time

when they reconnect 1-5 times it eventually gets in (server receives the message)

so i sended the ready message (client to server) every 10 seconds, but that also doesn’t helped

i also debugged, and there was not much traffic there

any ideas?

here is how i tracked the data (net.Incoming)
image

If you want to send a network request from the client to the server as soon as possible, you might want to use the HUDPaint hook in just the first frame (see description). This is what I have been using for years and it works all the time.

you linked PlayerInitialSpawn but in your text it says HudPaint, which one you mean? :smiley:
i mean PlayerInitialSpawn is only serversided right?

Look at the description and you will see the code I describe with HUDPaint.

i am confused there is no “HUDPaint”

Description:

Examples:

or did you mean in the github link?

i will try with HUDPaint now, which is called after InitPostEntity and hook.remove inside so it run just once

Oh sorry :sweat_smile:, I was sure there was the workaround with HUDPaint but the page has been updated in the meantime. However, you can also try with the InitPostEntity event you might get a better result

1 Like

i had InitPostEntity

but HUDPaint seems to work much better! :open_mouth:

actually it is only working for everybody when the State: SIGNONSTATE_FULL is done

hook.Add( "ClientSignOnStateChanged", "ClientSignOnStateChanged_ISREADY",
function( userID, oldState, newState )

    if newState == SIGNONSTATE_FULL then
        NETWORKSTATEREADY = true
    end

end )

so i only start sending the message when it has that state + hudpaint is run once

Yup, this looks pretty solid to me.

1 Like

this still persist

any other ideas?

current state:
i wait for SIGNONSTATE_FULL and hudpaint run once
then i send a message to the server
but some clients send it, but never reaches the server (5% or less of the players) (mostly they rejoin 3-5 times to finally get it working*)
i cant reproduce it on my own machine