Grow with AppMaster Grow with AppMaster.
Become our partner arrow ico

Cloudflare Workers Unveils connect() API Enabling Direct TCP Socket Creation

Cloudflare Workers Unveils connect() API Enabling Direct TCP Socket Creation

During the recent Developer Week 2023, Cloudflare revealed a new Worker API that empowers developers to establish outbound TCP sockets. This groundbreaking socket API enables developers to seamlessly connect to TCP-based infrastructures directly from a Worker, which now includes databases. Until now, Workers could only communicate with HTTP endpoints and other Cloudflare services; however, most databases necessitate clients to establish direct TCP sockets.

Brendan Irvine-Broque, Product Manager at Cloudflare, and Matt Silverlock, Director of Product at Cloudflare, elaborated on the new API: "With Workers, we aim to support standard APIs that are supported across browsers and non-browser environments wherever possible, (...) but for TCP sockets, we faced a challenge — there was no clear shared standard across runtimes. We’ve tried to incorporate the best elements of existing APIs and proposals, and intend to contribute back to future standards."

In the previous autumn, Cloudflare, Vercel, and Shopify established WinterCG, a new community group dedicated to creating interoperable implementations of standardized web APIs in non-web browser and JavaScript-based development environments.

The latest API can be accessed by importing the connect function from cloudflare:sockets. Though the JavaScript database driver for PostgreSQL, pg, already supports the new API, MySQL drivers—mysql and mysql2—are yet to support it. Irvine-Broque and Silverlock caution that:

A new connection is created for every request. This is one of the biggest current challenges of connecting to databases from serverless functions, across all platforms (...) we’re already working on simpler approaches to connection pooling for the most popular databases.

Cloudflare anticipates rolling out additional features in the future, such as inbound TCP and UDP connections support, which have been requested by developers, along with application protocols based on QUIC.

The introduction of the connect() API comes alongside several other exciting announcements during Developer Week 2023. These include the launch of the Secrets Store for securely managing application secrets, enhancements to D1 (Cloudflare's serverless database), and consumer concurrency for the Queues messaging service. Additionally, Cloudflare unveiled database integrations for Neon, PlanetScale, and Supabase on Workers.

Each opened TCP socket contributes to the maximum number of open connections that Workers can maintain simultaneously. Note that creating TCP connections on port 25 to send emails to SMTP mail servers is still not possible.

As no-code and low-code platforms like AppMaster continue to evolve, the introduction of features like the connect() API will further boost the development landscape by streamlining connections and creating new opportunities for developers.

Related Posts

AppMaster at BubbleCon 2024: Exploring No-Code Trends
AppMaster at BubbleCon 2024: Exploring No-Code Trends
AppMaster participated in BubbleCon 2024 in NYC, gaining insights, expanding networks, and exploring opportunities to drive innovation in the no-code development space.
FFDC 2024 Wrap-Up: Key Insights from the FlutterFlow Developers Conference in NYC
FFDC 2024 Wrap-Up: Key Insights from the FlutterFlow Developers Conference in NYC
FFDC 2024 lit up New York City, bringing developers cutting-edge insights into app development with FlutterFlow. With expert-led sessions, exclusive updates, and unmatched networking, it was an event not to be missed!
Tech Layoffs of 2024: The Continuing Wave Affecting Innovation
Tech Layoffs of 2024: The Continuing Wave Affecting Innovation
With 60,000 jobs cut across 254 companies, including giants like Tesla and Amazon, 2024 sees a continued wave of tech layoffs reshaping innovation landscape.
GET STARTED FREE
Inspired to try this yourself?

The best way to understand the power of AppMaster is to see it for yourself. Make your own application in minutes with free subscription

Bring Your Ideas to Life