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

Apple's AI-driven iOS 18 Promises Major Enhancements at WWDC 2024
Apple's AI-driven iOS 18 Promises Major Enhancements at WWDC 2024
Apple's WWDC 2024 will mark a significant shift with the AI-powered iOS 18, promising updates and changes to Siri, Apple Photos, Notes, Maps, and more.
Amid Criticism, Google Vows to Improve Flawed AI Search Overviews
Amid Criticism, Google Vows to Improve Flawed AI Search Overviews
Google commits to enhancing its AI Overviews after widespread criticism of inaccuracies and absurd responses, demonstrating the need for meticulous AI integration.
Live Nation Confirms Major Ticketmaster Data Breach, Personal Information Stolen
Live Nation Confirms Major Ticketmaster Data Breach, Personal Information Stolen
Live Nation confirmed a data breach affecting Ticketmaster’s customer information. The breach, identified on May 20, involves unauthorized activity in a third-party cloud database.
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