
Socket.IO P2P - Rauchg
http://socket.io/blog/socket.io-p2p/
======
angersock
It'd be nice if the socket.io project spent less time adding features and more
time just documenting what they have.

Does anybody have a small, fast, no-bullshit, modern websockets library they'd
nominate for use with node?

~~~
yid
Absolutely! I've had terrible experiences with vanilla socket.io regarding
reconnections, performance, and reliability. This is even after the 1.0
release.

Lately, I've been using primus [1], which is an API unification layer for
socket.io, sockjs, faye, and native websockets. Swapping one engine for
another is trivial, and they've taken pains to abstract a core subset of
functionality.

[1] [https://github.com/primus/primus](https://github.com/primus/primus)

~~~
amluto
Agreed. Mostly quoting myself from earlier this year: I don't normally like
bashing open-source projects, but socket.io should not be used. It may be
noob-friendly, but that's just because it does things so automatically that
you can't really use it correctly. When I was a websockets noob, I used
socket.io briefly, and it was a complete waste of time.

See, for example, [https://github.com/Automattic/socket.io-
client/issues/572](https://github.com/Automattic/socket.io-client/issues/572)
(closed without comment).

SockJS is much better, as is raw websockets. Presumably Primus, too, although
I'm a bit surprised that one can come up with a sensible interface that can be
layered over both Socket.io and anything else.

------
Jamie452
Personally I think PeerJS is a much more mature, robust and better documented
solution.

[http://peerjs.com/](http://peerjs.com/)

Last time I checked PeerJS also provides support for handling TURN/ICE/STURN.

~~~
akula1001
What's the state of this project? This issue seems to suggest the project is
dead.
[https://github.com/peers/peerjs/issues/290](https://github.com/peers/peerjs/issues/290)

------
peregrine
Is it documented anywhere how they handle TURN/ICE/STURN for dealing with
firewalls and routers?

EDIT: Looks like it doesn't. This is basically just a very small library on
top of socket.io. Look forward to them helping solve the TURN/ICE/STUN issues
:(

~~~
echeese
It's handled by simple-peer here: [https://github.com/feross/simple-
peer/blob/master/index.js#L...](https://github.com/feross/simple-
peer/blob/master/index.js#L126)

------
s986s
I'm humored by the fact that this example isn't working for me.

------
marknadal
Too bad the demo doesn't work, I was really excited for this. Regardless, big
congratulations to the Socket.IO team for an awesome feature! And props to
Feross for his simple-peer module, he is doing incredible work in the WebRTC
world.

In other news, to address some of the comments here:

\- As others have mentioned,
[https://github.com/sockjs](https://github.com/sockjs) is an alternative that
is more lean with less features.

\- I've also written an inverse websocket tool that behaves like a regular
HTTP request/response, but will proxy it through WebSockets or fallback to
JSONP. I really like this approach because it feels more RESTful, has less
overhead, and even allows the browser to do a `createServer`. It is currently
pretty tightly coupled into a project of mine (next bullet), I'll try pulling
it out into its own library if there is demand, but here is the source:

\- - Client library,
[https://github.com/amark/gun/blob/master/gun.js#L1138](https://github.com/amark/gun/blob/master/gun.js#L1138)
and onwards.

\- - Server library,
[https://github.com/amark/gun/blob/master/lib/wsp.js#L8](https://github.com/amark/gun/blob/master/lib/wsp.js#L8)
and onwards.

\- - Really nifty HTTP normalizer,
[https://github.com/amark/gun/blob/master/lib/http.js](https://github.com/amark/gun/blob/master/lib/http.js)
.

\- - Really nifty WebSocket normalizer, same format,
[https://github.com/amark/gun/blob/master/lib/ws.js](https://github.com/amark/gun/blob/master/lib/ws.js)
.

\- - Really nifty JSONP normalizer, same format,
[https://github.com/amark/gun/blob/master/lib/jsonp.js](https://github.com/amark/gun/blob/master/lib/jsonp.js)
.

\- If you do use the P2P Socket.IO feature, the next thing you'll need is a
P2P database that can run in the browser! And that is what my main open source
project, [http://gunDB.io/](http://gunDB.io/) is about. The previous bullet's
code is my nimble websocket and fallback library I wrote for this project, and
that is why they are currently tightly coupled - sorry about that. If there is
enough demand for it by itself then I'll try making it into its own library.

Cheers!

------
1qaz2wsx3edc
Neat, when can we expect a DHT (distributed hash table) for decentralization?
;)

~~~
rich90usa
[https://github.com/feross/bittorrent-
dht](https://github.com/feross/bittorrent-dht)

------
irascible
Can I use this to send udp+tcp between clients and servers?

