Open lilyannehall opened 8 years ago
Thx!
Sure, will add a README file later on this week.
And how to use this stuff?
@Globik The easiest way to get started is by checking out the example scripts -- you can find them in the examples dir. Both scripts setup relay connections between two sockets, and use these connections to exchange messages. One script exchanges these messages via STUN data packets, while the other example binds a TURN channel first to transmit data messages.
To test these example scripts, run
node channel_data.js --addr=TURN_ADDR --port=TURN_PORT --user=TURN_USER --pwd=TURN_PWD
or node channel_bind.js --addr=TURN_HOST --port=TURN_PORT --user=TURN_USER --pwd=TURN_PWD
If you're not running a TURN server yourself, you can create an account on the Numb STUN/TURN server and use these credentials when launching my example scripts.
@globik also, feel free to use turn.counterpointhackers.org - no credentials required
@nicojanssens , you said that one script exchanges via STUN and another via TURN, which one is STUN and which is TURN ??
sendToChannel == STUN sendToRelay == TURN
???
And where do we need mappedAddress ??
@iMihael That was a typo. Both scripts establish TURN connections. (The TURN protocol uses STUN packets, that's probably where my lapsus originates from).
@iMihael The mappedAddress is not required to establish a bidirectional connection between two clients. It specifies a client's mapped public address -- which is the address of the NAT box a client is located behind.
If it possible to use (establish) stun connection between two peers, will your lib use this variant to decrease turn server load ??
@iMihael you mean a direct connection between two nodes located behind a NAT box? Nope, this lib does relaying only. It does not iterate over various connectivity strategies like WebRTC does using ICE -- first trying to connect two peers using their private addresses, then using their server reflexive address and finally establishing a relay connection if all other options failed.
It's on my todo list (I implemented a udp hole punching lib for that purpose, see https://github.com/nicojanssens/udp-hole-puncher-js) but I didn't find the time yet to complete this.
Btw, you may want to have a look at the kad-traverse module of @gordonwritescode. Gordon implemented a strategy like the one I explained above, such that TURN connections are only used if all other connection attempts have failed. GH repo: https://github.com/kadtools/kad-traverse
Thank you for answer!
Hey! Nice work! I'd love to incorporate TURN as a transport middleware for [kad](github.com/gordon writescode/kad). Any ideas when you might have some documentation to help?
For now I'll use the source!