Geckos UDP Packet Order

Yo @yannick … Got a question about the UDP packet order.

Since UDP packets are not guaranteed to be in order, and you can receive packet 5 before packet 4 for example… Does the ( like) api take that into account. when i do something like channel.on(‘chat message’)… Will they always be in order… Or can you still get out of order messages with ?


How do you send message back to the client sender only… and not all the the other channels in the room ?

Thanks for the great work on, btw :slight_smile:

There seems to be an options.ordered option for initializing the server

There’s also:

// emits a message to the channel
channel.emit('chat message', 'Hello to myself!')

// emits a message to all channels, in the same room'chat message', 'Hello everyone!')

// emits a message to all channels, in the same room, except sender
channel.broadcast.emit('chat message', 'Hello friends!')

// emits a message to all channels
io.emit('chat message', 'Hello everyone!')

Reference: GitHub - geckosio/ 🦎 Real-time client/server communication over UDP using WebRTC and Node.js

R there any drawback or performance issues with setting options.ordered = true ???

I’m not sure, but my guess is that ordered may cause you to lose the non-blocking benefit of unreliable, unordered UDP

I think if you’re dealing with user-typed chat messages on top of multiplayer networking, unordered should be fine, since a typical user won’t send typed messages at sub-second frequency, so the chance that their chat messages are out of order is low

I was thinking about using ordered = true for adding snapshot packets from network to my interpolation buffer. But if that negates any SPEED benefits… I will stick to un ordered and try and INSERT my network packet into the interpolation buffer array based on a sequence number or something

Yo @yannick … is it possible to rebuild the package with CommonJS ?

I cant get my servers to run at AWS… I guess its using a older node 14 (not sure the minor version)
and wont run on AWS Beanstalk Server

FYI @yannick … When trying to deploy my app to AWS Elastic Beanstalk Environment.
It get a permission error when trying to install a package called node-datachannel

I gues the node-datachannel packge install is trying to access the resources on the machine like /root/.npm and ./root/.npm/_logs

So i cant deploy my app in the cloud on AWS :frowning:

Yes, exactly.

No. Please use dynamic imports in a CJS project or switch to ESM.

I don’t know. But try
sudo chown R 900:900 "/root/.npm"

YO @yannick … I am trying to use typed array buffer with udp data channels… but when i transmit a arraybuffer with io… i just get an empty javascript… I have the same function but sending with colyseus broadcast and is working fine… can receive arraybuffer on client and work great with snapshotModel.fromBuffer

So… how do i get the UDP data channels to support sending binary data… like the result for snapshotModel.toBuffer

This is how i am generating worldState … using that to create a snapshot and converting that to binary array buffer… Then transmitting that binary packet either with or

Found it… Raw Message… Looks like you cant specify a message type like with emit… Just the raw message itself… That kool… i can work with that :slight_smile:

1 Like

Yo @yannick … is client outbound compression from javascript to nodejs supported ?

I was trying to do just that… But on node js side… the onMessage(data) that is received is a Node.JS Buffer and not a Javascript ArrayBuffer

So i try to something like:

const packet:any = (data instanceof Buffer) ? UpdateModel.fromBuffer(data.buffer) : data;

But it get offset outside the bounds error

Have you ever used compression on the packet you send from the client to the nodejs server ?