# WebRTC communication between two Snap!s

I just published some WebRTC blocks that enables two Snap!s to send strings and lists to each other. It relies upon WebRTC a peer-to-peer communication standard supported by many browsers (tested in Chrome and FireFox). Because it doesn't use a server to create a connection it is a bit clumsy in that the two collaborators need to exchange some keys (e.g. via email or memory keys) and paste them into the appropriate blocks to create a connection.

The same connection can be used to create audio or video links but I haven't explored this.

It should be possible to build upon these blocks to support collaborative programming as in NetsBlox. Perhaps a better job for someone more familiar with the innards of Snap!

Cool! Yes, that's a good start toward collaborative programming, although we might end up preferring to follow NetsBlox's lead more closely. Thanks.

Ooooh, I love this! The idea of a serverless peer-to-peer collaboration system is extremely appealing.

I just tried it out, and it looks really cool. I especially like the fact that you can specify exactly what happens to a message.

It isn't working for me. The start connection block doesn't open an ask box. Is there any way to connect two clients by only moving a key one way, and the other key is transferred by this protocol?

Thanks for reporting this. I just did some testing and I did have troubles getting Chrome and FireFox to communicate but I got it working with two Chrome instances.

But your problem seems to happen when loading the WebRTC code since once it is loaded the ask is run. Did you look at the browser's console to see if there is an error message when loading the code?

What browser are you using?

https://ecraft2learn.github.io/ai/js/webrtc.js didn't load because noscript was blocking it. My fault. It works now. Is there any way to transmit only one key?
EDIT: I also get

iceConnectionState is checking [webrtc.js:38:19](https://ecraft2learn.github.io/ai/js/webrtc.js)

iceConnectionState is failed [webrtc.js:38:19](https://ecraft2learn.github.io/ai/js/webrtc.js)

WebRTC: ICE failed, add a TURN server and see about:webrtc for more details


I'm pretty sure there needs to be 2 keys. See https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection

I'm not an expert why the ICE may have failed but it is configured to go to stun:stun.l.google.com:19302 which should be reliable and reachable. Here's a stackoverflow discussion of this.

Sorry for neroposting, but I have a question, when I press Start collaboration and type something in,

EDIT: Nevermind, I found it out.

[offtopic]Ah... why am I posting at 2 AM? I stay up wayyyyyy to late.[/offtopic]

Why was I pinged on this topic?

Please dont reply to an old topic - even if you got pinged, it is still considered necroposting.

I can't figure out how to use this. @toontalk can you guide be through step-by-step?

I connected, but when I try to send a message, it says "TypeError:
conection.sctp is undefined.
"

According to RTCPeerConnection.sctp - Web APIs | MDN this is only supported by Chrome and Edge. I just tried connecting between Chrome and Edge and it worked fine.

Just tried it out between Chrome and Vivaldi on my win10 machine and it worked fine

When I send my code to a friend, the message to enter the code never shows up. (Chrome on a Chomebook)

Are they enabling JS?

Are they clicking on accept collaboration block?

Yep.

possibly one or both of you are firewalled or maybe don't have access to github