> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joinmassive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What is the difference between a sticky session and a TCP connection?

A common source of confusion is the relationship between **sticky sessions** and **TCP connections**. They are independent concepts that operate at different layers.

## TCP Connection (Transport Layer)

A TCP connection is the underlying network link between your client and the Massive proxy server. It carries the actual bytes of your HTTP/HTTPS/SOCKS5 requests.

* **Idle timeout**: Open TCP connections automatically close after **30 seconds of inactivity**
* **Scope**: A single request (or a series of keep-alive requests on the same socket)
* **Lifetime**: Typically seconds to minutes, depending on activity

When a TCP connection closes, it does **not** mean your sticky session has expired or that a new IP has been assigned.

## Sticky Session (Application Layer)

A sticky session is a logical mapping between your session ID and a specific proxy node (IP address). It is tracked server-side and persists independently of TCP connections.

* **Default TTL**: 15 minutes (customizable up to 240 minutes via `sessionttl`)
* **TTL is static**: Set at creation time, not extended by subsequent requests
* **Scope**: All requests sharing the same session ID, regardless of how many TCP connections they use
* **Lifetime**: Minutes to hours, controlled by `sessionttl` parameter.

## How They Work Together

Within a single sticky session, many TCP connections can open and close — your IP stays the same throughout.

<Steps>
  <Step title="0:00 — First request">
    TCP connection opens → Request with `session-abc` → Assigned to IP **1.2.3.4** → TCP connection closes.
  </Step>

  <Step title="0:45 — Second request (45 seconds later)">
    New TCP connection opens → Same `session-abc` → Still routed to IP **1.2.3.4** → TCP connection closes.
  </Step>

  <Step title="3:00 — Third request (3 minutes later)">
    New TCP connection opens → Same `session-abc` → Still IP **1.2.3.4**. Session is alive until TTL expires.
  </Step>

  <Step title="15:00 — Session TTL expires">
    The 15-minute sticky session ends. The IP **1.2.3.4** is no longer reserved for `session-abc`.
  </Step>

  <Step title="15:01 — Next request">
    New TCP connection opens → Same `session-abc` → New session created → New IP **5.6.7.8**.
  </Step>
</Steps>

<Note>
  TCP connections closed 3 times in this example, but the IP never changed until the session TTL expired.
</Note>

## Key Takeaway

|                  | TCP Connection                          | Sticky Session                 |
| ---------------- | --------------------------------------- | ------------------------------ |
| **What it is**   | Network socket between client and proxy | Logical IP-to-session mapping  |
| **Idle timeout** | 30 seconds                              | None (static TTL)              |
| **Max lifetime** | As long as data flows                   | 240 minutes (`sessionttl-240`) |

<Info>
  The 30-second idle timeout applies to the TCP connection, not the session TTL. If your TCP connection closes due to inactivity, simply open a new connection with the same session ID — you will get the same IP as long as the session TTL has not expired.
</Info>

For more details on session modes and configuration, see the [sticky sessions documentation](/residential/sticky-sessions).
