Menu

A New HttpClient on Every Call Exhausts TCP Ports. Reuse One Client, or Use IHttpClientFactory
📰

A New HttpClient on Every Call Exhausts TCP Ports. Reuse One Client, or Use IHttpClientFactory

DEV Community: dotnet·Aimpex Resources Group LLC·8 days ago
#bJldRtQD
#devtodotnet#devto#dev#client#httpclient
Long article (1388 words) — no AI summary yet.
Reading 0:00
15s threshold

A small .NET service can look healthy in a quiet test. Then it can fail on a busy morning because it opens a new network client for every call. The failure is often a shortage of TCP ports, not a bug in the ERP API it is calling.

Some quick terms first. HttpClient is the .NET class that sends HTTP requests and reads the replies. HTTP is the protocol used by most web and REST APIs. A connection pool is a set of open network connections that a client can reuse. TCP is the transport that carries those connections. After a connection closes, the operating system keeps its port in a short "TIME-WAIT" state, so the port cannot be used again at once. Domain Name System, or DNS, is the directory that maps a name such as api.example.com to a network address.

This write-up is from Aimpex Resources Group LLC. Our Lincoln, NE team works on ERP Architecture across SAP S/4HANA, Oracle Cloud ERP and Microsoft Dynamics. We place .NET engineers on the integrations that pull that data into other tools.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.