NetRay - High-Performance Roblox Networking Library

this is mine

function ServerEvent:FireAllClients(data)
	-- Type checking if enabled
	if self.TypeDefinition then
		local typeCheckResult = TypeChecker:Validate(data, self.TypeDefinition)
		if not typeCheckResult.success then
			error(string.format("[NetRay] Type validation failed for event %s: %s", 
				self.Name, typeCheckResult.error or "Unknown error"))
			return
		end
	end

	-- Run middleware
	local processedData = self.ServerManager:InvokeMiddleware(self.Name, nil, data)
	if processedData == false then
		-- Middleware blocked this event
		return
	end

	-- Use DynamicSender to optimize batch sending
	local sendData = processedData or data
	local allPlayers = Players:GetPlayers()

	-- Use SendToMultiple for batch optimization
	local result = DynamicSender:SendToMany(self.RemoteEvent, sendData, allPlayers)

	-- Log the batch send if debugging is enabled
	if self.ServerManager.DebugEnabled then
		print(string.format("[NetRay] Event %s fired to %d clients with batch optimization", 
			self.Name, #allPlayers))
	end
end
1 Like

I think I know the issue: You’re trying to send the data before the player can receive/load in.

replace SendToMany Function with this; it will stop the error but won’t guarantee your client will get it

function NetRaySender:SendToMany(remote: RemoteEvent, data: any, targets: { Player })

	if not remote then
		warn("[NetRaySender] Cannot SendToMany: RemoteEvent is nil.")
		return
	end

	-- Prepare single item data once, marked as NOT batch
	local preparedData = prepareDataForSend(data, false, NetRaySender.Config.ForceCompressSingle) -- isBatch = false
	if not preparedData then
		warn("[NetRaySender] Failed to prepare data for SendToMany:", data)
		return
	end

	if NetRaySender.Config.DebugMode then
		print(`[NetRaySender] Sending to { #targets } targets via SendToMany.`)
	end
	
	if not targets or #targets == 0 then
		remote:FireAllClients(preparedData)
	else
		for _, target in ipairs(targets) do
			if target and target.Parent then
				remote:FireClient(target, preparedData)
			end
		end
	end

end

Netray v1.1.0 - Alpha - Benchmarks

NetRay v1.1.0 isn’t out yet; I am still refining the dynamic sender and batching logic even more, but here is a video of a benchmark compared to other modules.

Modules in benchmark place (Not Mine)
versions:
bytenet: 0.4.3
zap: 0.6.19
blink: 0.17.0
packet: 1.2
netray 1.1.0

Note

  • Packet and Netray throttling were both disabled to get a fair result
  • NetRay v1.1.0 is still being refined and tested so results are not final

Results

  • NetRay and Blink have the lowest usage for bools (seems like Netray is slightly lower eyeballed)
  • NetRay performs the same on structofnumbers as the rest with the notable exception of blink, which performed the best
  • NetRay did send less packet data per frame compared to others, but the struct of numbers did have slightly higher overall kb/s sent on the roblox performance stats

No CPU or Ping changes or high usage, and FPS was stable

Video

My PC Specs are listed in the video description

Testing Place

  • I didn’t change anything besides the netray module version and disabled throttling as seen in the video

Benchmark (1).rbxl (281.2 KB)

1 Like

I attached the testing place above now with a video if you want to test it yourself :+1:

21:45:16.374  StructOfNumbers  -  Client - Benchmark:46
21:45:33.878  Blink: 0.000163 | Avg Kbps: 117.88912232716878 | Avg FPS: 242.35274702147333  -  Client - Benchmark:63
21:45:51.471  Packet: 0.001318 | Avg Kbps: 118.24619567871093 | Avg FPS: 241.6646687562206  -  Client - Benchmark:114
21:46:18.586  NetRay: 0.005525 | Avg Kbps: 109.85877458439317 | Avg FPS: 135.58654298212463  -  Client - Benchmark:131
21:58:25.473  Entities  -  Client - Benchmark:46
21:58:42.999  Blink: 0.000627 | Avg Kbps: 290.27935791015625 | Avg FPS: 240.07260974414928  -  Client - Benchmark:63
21:59:12.009  Packet: 0.004187 | Avg Kbps: 282.4741762851147 | Avg FPS: 125.7746591977079  -  Client - Benchmark:114
22:00:06.661  NetRay: 0.014191 | Avg Kbps: 5686.389995771585 | Avg FPS: 60.44602778774181  -  Client - Benchmark:131
-- Entities
local amount = 50
local array = table.create(amount)
for index = 1, amount do
	local random = Random.new(index*index)
	table.insert(array, {
		brand = string.char(random:NextInteger(0, 255)):rep(random:NextInteger(2, 100)),
		carName = string.char(random:NextInteger(0, 255)):rep(random:NextInteger(2, 100)),
		carId = random:NextInteger(0, 65535),
		carColor = Color3.fromRGB(random:NextInteger(0, 255), random:NextInteger(0, 255), random:NextInteger(0, 255)),
		available = random:NextInteger(0, 1) == 1,
		dealers = random:NextInteger(0, 127),
		price = random:NextNumber(0, 1e12),
	})
end
return array

u may also have to check memory leak’s on profiler & memory not just benchmarking all day :nerd_face:

I benchmarked twice, one before the video and the video???
seems you have a issue with NetRay being a good networking module

Also

My Memory with and without netray on the benchmarked were both 3.1gb in studio so…

You seem very obsessed with finding specific ways in iterating tables within a table to try to get your desired outcome

Plus I did say it’s still crude and barebones of v1.1.0 since I have barely finished it

1 Like

dont forget to give credit to suphi for using Cursor & Types module in ur v1.1.0, i see u copy pastes it and modifies some codes without giving credit on it.

This was in Netray v1.0.0 bro :sob: I used some types and did my own so like, your issue?

I also fixed issues with his cursor and types modules and expanded on them, no point of start from scratch again to get the same thing

You seem more obsessed with trying to make the module look bad than anything else in your sorry life, You can go outside; you know that,t right?

Like I already said, I used parts for a base because I was already making one but he released it and I just modified and improved it and works better and with NetRay so I still don’t see your point?

you seem quite mad :sob:

No, his module just had issues and kept going out of bounds when I tested his module, and couldn’t handle tables etc

re-read what i said before, and also u said ur using it since v1.0.0 but i dont see ur giving any credit to him :face_with_monocle:

If you lack basic comprehension skills not my issue anymore You can go on hating if you want, but no one takes you seriously :sob:

You’re so pressed, it’s laughable

NetRay v1.1.0

  • Updated and improved Binary Encoder (v1.5.3)
  • Rewrote compression algorithm (switched from LZW to LZ4)
  • Eliminated CPU usage
  • Eliminated all Ping issues
  • Eliminated FPS issues
  • Fix Minor bugs
  • Fixed unable to send blank remote calls
  • Rewrote Dynamic Sender (v1.2.8)
  • Improved Promise module
  • Rewrote all modules for proper type checking, etc
  • Implement Autocomplete functionality (for the most part)

Benchmarks

  • Peforms Better or as good as Blink in some cases
  • In other cases, it performs as well or has slightly more network usage for very complex tables
    This is because netray automatically does everything for you and includes headerdata since it doesn’t use pre-defined structures, however, it is not that much overall, only a few kb.

Dynamic Sender Rewirte

  • Now Dynamic Sender chooses the best option to send and serialises it for you without using the seriliastion module
  • Uses a complex metadata analysis to determine the best ways to send your data

GitHub
Roblox

1 Like

Would it be possible for you to eliminate the 201 warnings that pop up in the script analysis when i insert the NetRay module into my game?

What are the warnings? Could you please share
you can just ignore them as they aren’t really warnings or anything

202 minus the one warning that has been there prior me inserting the module


edit: its not possible for me to ignore the warnings as i am trying to keep my game as clean as possible and i am frequently using the code analysis to eliminate type issues and the NetRay module makes it really hard for me to find issues that come from my game.

1 Like

This is a pretty cool OSS project! The haters are out there but you can ignore them for the most part; they only exist to suck up your energy and prevent you from making your project the best it can be. Keep up the good work!

4 Likes

This is weird, I don’t have these issues. Is that v1.1.0?

Yes this is the newest version i just grabbed from the github repo

1 Like

Try using this
Roblox
I just re-uploaded it to Roblox

NetRayNew.rbxm (148.5 KB)

You can also try that one

Enabling --!strict typechecking just makes more warnings pop up. Would you mind strictly typing the module in the future? This would make your job way easier.

Edit: The 201 warnings are still there after using the re-uploaded version.

2 Likes