DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  • Building Resilient Networks: Limiting the Risk and Scope of Cyber Attacks
  • Detection and Mitigation of Lateral Movement in Cloud Networks
  • Understanding IEEE 802.11(Wi-Fi) Encryption and Authentication: Write Your Own Custom Packet Sniffer

Trending

  • Simplifying Multi-LLM Integration With KubeMQ
  • Integrating Model Context Protocol (MCP) With Microsoft Copilot Studio AI Agents
  • How to Ensure Cross-Time Zone Data Integrity and Consistency in Global Data Pipelines
  • Simpler Data Transfer Objects With Java Records
  1. DZone
  2. Data Engineering
  3. IoT
  4. Towards a WebRTC Mesh Network With RTCDataChannel [Livecoding]

Towards a WebRTC Mesh Network With RTCDataChannel [Livecoding]

In this livecoding session, we pick up where we left off last time, working on our WebRTC network that allows for peer-to-peer communication.

By 
Swizec Teller user avatar
Swizec Teller
·
May. 31, 18 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
6.9K Views

Join the DZone community and get the full member experience.

Join For Free

It didn't work. We don't have a mesh network yet. But we're so close that I can almost smell it.

The ultimate goal is to build a JavaScript library that can connect arbitrary browsers through a mesh network using a sort of blockchain as the algorithm to ensure distributed data correctness. Why? Intellectual curiosity.

Previously, we figured out how to connect two browsers running on different computers with a video connection. A signaling server helps with the initial handshake, then the browsers communicate directly using WebRTC. No more server.

WebRTC also supports so-called data channels using RTCDataChannel.

It works like this:

  1. Use signaling server to establish a peer connection.
  2. Add a data channel to said connection.
  3. Send from each side.

Data can be anything. We're using "Hello World" strings, for now, and we'll be using serialized JSON objects later. Rumors say you could send whole files.

This all sounds very simple. Even when you look at the code that's required.

We add a RTCDataChannel to our peer connection and attach a bunch of event handlers. Errors for complaining, messages for printing, and we try to send a message when the channel opens.

The cool part is that we can attach this channel before a connection is fully established.

See, both clients finish with saying Data channel open.

But no data is sent or received, and there's no error.

I suspect this is because while the data channel is open, the peer connection itself is not established. That pesky WebRTC lifecycle error about doing something or another in the wrong step.

This part used to work. Therefore, I must have broken something when deleting a bunch of code that seemed unnecessary.

We also generally spent a lot of time mucking around making this lifecycle more robust because it was hella flaky before.

Getting close!

Network

Published at DZone with permission of Swizec Teller, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  • Building Resilient Networks: Limiting the Risk and Scope of Cyber Attacks
  • Detection and Mitigation of Lateral Movement in Cloud Networks
  • Understanding IEEE 802.11(Wi-Fi) Encryption and Authentication: Write Your Own Custom Packet Sniffer

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!