shovon / node-rudp Goto Github PK
View Code? Open in Web Editor NEWReliable UDP for Node.js
Reliable UDP for Node.js
I have spent some hours trying to get this thing to work, without success. Tried to set up the file sharing example, and add some console.logs to understand where it goes wrong.
Here is my setup. And the output from the processes. Everyone is run on separate machines, but client and server are behind the same NAT.
Mediator
# node mediator.js -p 5000
Registered a0af11ac, from host 194.140.150.160
Server
# node app.js -m 194.142.159.165:5000 -f ~/Documents/test.txt
Requesting to register a0af11ac
Got request to talk to remote host at 194.140.150.160, 51036
Sending the file /home/akaustel/Documents/test.txt 1588 bytes (sending 1596 bytes)
Client
# node app.js -m 194.142.159.165:5000 -t a0af11ac
Requesting to talk to a0af11ac
Got request to talk to remote host at 194.140.150.160, 48317
Just waiting on a file.
I would be very happy to get some pointers to get this working!
would be nice to be able to do something like this:
client.send(data, function() {
// the packets this data was split up into have all been acknowledged
})
thanks for the great lib!
here's the breaking test:
var rudp = require('rudp');
var dgram = require('dgram');
var billSocket = dgram.createSocket('udp4');
var tedSocket = dgram.createSocket('udp4');
billSocket.bind(function() {
tedSocket.bind(function() {
var billClient = new rudp.Client(billSocket, '127.0.0.1', tedSocket.address().port);
var tedClient = new rudp.Client(tedSocket, '127.0.0.1', billSocket.address().port);
tedClient.on('data', function(data) {
billClient.close()
tedClient.close()
})
billClient.send(new Buffer('excellent!'))
})
})
and here's the error stack trace:
dgram.js:439
throw new Error('Not running'); // error message from dgram_legacy.js
^
Error: Not running
at Socket._healthCheck (dgram.js:439:11)
at Socket.send (dgram.js:282:8)
at PacketSender.send (/Users/tenaciousmv/Code/node-rudp/lib/PacketSender.js:13:16)
at null.<anonymous> (/Users/tenaciousmv/Code/node-rudp/lib/PendingPacket.js:23:24)
at wrapper [as _onTimeout] (timers.js:287:14)
at Timer.listOnTimeout (timers.js:133:15)
there is a test from your example,
when msg greater than 512,it will splite to some mini msg(512)
and not rebuild in other peer.
var gobackn = require('../../lib');
var dgram = require('dgram');
var serverSocket = dgram.createSocket('udp4');
var clientSocket = dgram.createSocket('udp4');
serverSocket.bind(3001);
console.log('Bound the server socket to port 3001');
var server = new gobackn.Server(serverSocket);
var client = new gobackn.Client(clientSocket, '127.0.0.1', 3001);
server.on('close', function () {
serverSocket.close();
});
client.on('close', function () {
clientSocket.close();
});
server.on('connection', function (connection) {
connection.on('data', function (data) {
console.log('data:' + data.toString('utf8'));
});
connection.send(new Buffer('Hello, Client!'));
});
client.on('data', function (data) {
console.log('Client: %s', data.toString('utf8'));
});
var info = '';
for(var i = 0; i < 16*1024; i ++)
info += ' ' + i;
client.send(new Buffer('Hello, World!'));
client.send(new Buffer('How are you doing?'));
client.send(new Buffer(info));
Hey,
I don't think it's an issue with this repo but it seems like I can't use buffertools in my project. I'm getting an error saying undefined symbol or something. Can I use Buffer.compare instead of buffertools?
Hey,
Would you please also provide an example for the Server part?
How can I get the data after the server received any? shouldn't be a listener on connection and emit the data after?
As was tangentially discussed in #7, rudp
would become a much better library if it had support for streaming. /cc @mvayngrib
Hi,
I'm trying to use the Server and my problem is as part of the dgram.socket I can use 'message' listener to get 'data' and 'remote' which contains source address and port of the sender.
How can I get this information using this library?
Heyyy it's me again :D
So I have a new problem.
The thing is I encrypt my data before sending it to my client and the client has to decrypt the data obviously! So I add some data before the real data as a header and I validate the header on the client. So if I couldn't read the header correctly that means there is something wrong with the data.
which is happening when I'm using the library. Should I split the data before sending it? Is there something that I'm missing here?
How should I approach this problem?
How would the library react if packets received unordered?
Thanks <3
When A sends a msg M to B, B should be able to know when it's received the entire message M (as opposed to 'data', which is a fragment of M).
From a usage perspective, maybe something like:
a.send(aLongMessage)
b.on('message', function (msg) {
// msg === aLongMessage
})
it's kind of a weird case, but I have the rudp client sharing a socket, and the rudp client ends up getting confused, misinterpreting packets not meant for itself
Does this use some form of UDP hole punching? If so, then wouldn't this require a separately hosted rendezvous server? If this isn't the method used could you give a high level overview of what is happening? Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.