Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are WebRTC SDP blobs reusable between peers?

I'm trying to use WebRTC for purely decentralised and peer-to-peer communications. I'm trying to build a P2P overlay network, wherein nodes exchange details of other nodes so that they may connect to them.

If I exchange SDP blobs (session description objects) between nodes, are they reusable in the sense that I could establish a connection to a node simply given this blob and an ICE candidate?

like image 329
liamzebedee Avatar asked Oct 03 '22 15:10

liamzebedee


1 Answers

Generally no: you need an offer from the source PeerConnection; there's no guarantee that a blob for PC1 can be used with PC2 (and likely can't). Now, if they've created a peerconnection, done CreateOffer, and hold onto the peerconnection until that SDP gets used - then yes, but that' not really "re-use".

You might get away with it, but various things now or in the future might break you semi-randomly. The best solution is to create an offer from the source node, and pass it over the p2p network to the target node, which can then pass a response back. If you can keep a PC alive to wait for incoming transactions, the "source" could use that for createAnswer, and cut one trip through the p2p network. You'd need to deal with collisions (two nodes trying to use the same offer that was distributed through the network; basically a fail/retry setup should handle it in the rare cases it's needed). You can also include with the answer an offer to use just in case there's a collision.

like image 54
jesup Avatar answered Oct 07 '22 19:10

jesup