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

Samsung Unveils Galaxy A55 with Innovative Security and Premium Build
Samsung Unveils Galaxy A55 with Innovative Security and Premium Build
Samsung broadens its midrange lineup introducing the Galaxy A55 and A35, featuring Knox Vault security and upgraded design elements, infusing the segment with flagship qualities.
Cloudflare Unveils Firewall for AI to Shield Large Language Models
Cloudflare Unveils Firewall for AI to Shield Large Language Models
Cloudflare steps ahead with Firewall for AI, an advanced WAF designed to pre-emptively identify and thwart potential abuses targeting Large Language Models.
OpenAI's ChatGPT Now Speaks: The Future of Voice-Interactive AI
OpenAI's ChatGPT Now Speaks: The Future of Voice-Interactive AI
ChatGPT has achieved a milestone feature with OpenAI rolling out voice capabilities. Users can now enjoy hands-free interaction as ChatGPT reads responses aloud on iOS, Android, and web.
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