Dashboard
Products / Residential Proxies

Session Control & IP Rotation

By default, every new connection gets a new residential IP. Add a session ID to keep the same IP for up to 30 minutes: for logins, carts and multi-step flows.

Modes

ModeUsernameBehaviourBest for
Rotatingcrh_USERNAME__cc_usNew exit IP on each new proxy connectionLarge-scale scraping, one page per request
Stickycrh_USERNAME__cc_us__sid_cart42Same exit IP for up to 30 minutes for every connection that uses this session IDLogins, checkouts, paginated flows

Rotation happens per connection

Rotation is tied to the connection, not the request. HTTP clients reuse connections (keep-alive), so several requests in a row can share one exit IP. To force a new IP for every request, open a new connection each time.

Rotating example

No session ID: each new connection gets a new IP.

curl -x http://proxy.crawlhub.ai:8000 \
  -U "crh_USERNAME__cc_us:PASSWORD" \
  https://ipinfo.io/json
import requests

username = "crh_USERNAME__cc_us"
password = "PASSWORD"
proxy = f"http://{username}:{password}@proxy.crawlhub.ai:8000"

response = requests.get(
    "https://ipinfo.io/json",
    proxies={"http": proxy, "https": proxy},
    timeout=30,
)
print(response.json())
// npm install undici
import { fetch, ProxyAgent } from "undici";

const auth = Buffer.from("crh_USERNAME__cc_us:PASSWORD").toString("base64");
const agent = new ProxyAgent({
  uri: "http://proxy.crawlhub.ai:8000",
  token: `Basic ${auth}`,
});

const res = await fetch("https://ipinfo.io/json", { dispatcher: agent });
console.log(await res.json());
<?php
$ch = curl_init("https://ipinfo.io/json");
curl_setopt($ch, CURLOPT_PROXY, "http://proxy.crawlhub.ai:8000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "crh_USERNAME__cc_us:PASSWORD");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

echo curl_exec($ch);
curl_close($ch);
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "time"
)

func main() {
    proxyURL, _ := url.Parse("http://crh_USERNAME__cc_us:PASSWORD@proxy.crawlhub.ai:8000")
    client := &http.Client{
        Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
        Timeout:   30 * time.Second,
    }
    resp, err := client.Get("https://ipinfo.io/json")
    if err != nil { panic(err) }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
import java.net.*;
import java.net.http.*;

public class Main {
  public static void main(String[] args) throws Exception {
    // Java blocks Basic auth on HTTPS tunnels by default; allow it.
    System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");

    HttpClient client = HttpClient.newBuilder()
      .proxy(ProxySelector.of(new InetSocketAddress("proxy.crawlhub.ai", 8000)))
      .authenticator(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("crh_USERNAME__cc_us", "PASSWORD".toCharArray());
        }
      }).build();

    HttpRequest req = HttpRequest.newBuilder(URI.create("https://ipinfo.io/json")).build();
    System.out.println(client.send(req, HttpResponse.BodyHandlers.ofString()).body());
  }
}
using System.Net;

var proxy = new WebProxy("http://proxy.crawlhub.ai:8000")
{
    Credentials = new NetworkCredential("crh_USERNAME__cc_us", "PASSWORD")
};
using var client = new HttpClient(new HttpClientHandler { Proxy = proxy, UseProxy = true })
{
    Timeout = TimeSpan.FromSeconds(30)
};

Console.WriteLine(await client.GetStringAsync("https://ipinfo.io/json"));
require "net/http"

uri = URI("https://ipinfo.io/json")
proxy = ["proxy.crawlhub.ai", 8000, "crh_USERNAME__cc_us", "PASSWORD"]

Net::HTTP.start(uri.host, uri.port, *proxy, use_ssl: true, read_timeout: 30) do |http|
  puts http.get(uri.path).body
end

Sticky sessions

Add __sid_ and any ID you choose to your username. Every connection that uses the same username gets the same IP.

PropertyValue
Parameter__sid_, always the last suffix
Session ID1–32 letters or digits, chosen by you, e.g. job01, a3f09c1b
LifetimeUp to 30 minutes, fixed. Can't be changed per request.
ScopeThe whole username. Same session ID with a different location is a different session.
Number of sessionsUse as many session IDs as you need in parallel

Sticky example

Session job01 in the US. Every connection with this username uses the same IP.

curl -x http://proxy.crawlhub.ai:8000 \
  -U "crh_USERNAME__cc_us__sid_job01:PASSWORD" \
  https://ipinfo.io/json
import requests

username = "crh_USERNAME__cc_us__sid_job01"
password = "PASSWORD"
proxy = f"http://{username}:{password}@proxy.crawlhub.ai:8000"

response = requests.get(
    "https://ipinfo.io/json",
    proxies={"http": proxy, "https": proxy},
    timeout=30,
)
print(response.json())
// npm install undici
import { fetch, ProxyAgent } from "undici";

const auth = Buffer.from("crh_USERNAME__cc_us__sid_job01:PASSWORD").toString("base64");
const agent = new ProxyAgent({
  uri: "http://proxy.crawlhub.ai:8000",
  token: `Basic ${auth}`,
});

const res = await fetch("https://ipinfo.io/json", { dispatcher: agent });
console.log(await res.json());
<?php
$ch = curl_init("https://ipinfo.io/json");
curl_setopt($ch, CURLOPT_PROXY, "http://proxy.crawlhub.ai:8000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "crh_USERNAME__cc_us__sid_job01:PASSWORD");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

echo curl_exec($ch);
curl_close($ch);
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "time"
)

func main() {
    proxyURL, _ := url.Parse("http://crh_USERNAME__cc_us__sid_job01:PASSWORD@proxy.crawlhub.ai:8000")
    client := &http.Client{
        Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
        Timeout:   30 * time.Second,
    }
    resp, err := client.Get("https://ipinfo.io/json")
    if err != nil { panic(err) }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
import java.net.*;
import java.net.http.*;

public class Main {
  public static void main(String[] args) throws Exception {
    // Java blocks Basic auth on HTTPS tunnels by default; allow it.
    System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");

    HttpClient client = HttpClient.newBuilder()
      .proxy(ProxySelector.of(new InetSocketAddress("proxy.crawlhub.ai", 8000)))
      .authenticator(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("crh_USERNAME__cc_us__sid_job01", "PASSWORD".toCharArray());
        }
      }).build();

    HttpRequest req = HttpRequest.newBuilder(URI.create("https://ipinfo.io/json")).build();
    System.out.println(client.send(req, HttpResponse.BodyHandlers.ofString()).body());
  }
}
using System.Net;

var proxy = new WebProxy("http://proxy.crawlhub.ai:8000")
{
    Credentials = new NetworkCredential("crh_USERNAME__cc_us__sid_job01", "PASSWORD")
};
using var client = new HttpClient(new HttpClientHandler { Proxy = proxy, UseProxy = true })
{
    Timeout = TimeSpan.FromSeconds(30)
};

Console.WriteLine(await client.GetStringAsync("https://ipinfo.io/json"));
require "net/http"

uri = URI("https://ipinfo.io/json")
proxy = ["proxy.crawlhub.ai", 8000, "crh_USERNAME__cc_us__sid_job01", "PASSWORD"]

Net::HTTP.start(uri.host, uri.port, *proxy, use_ssl: true, read_timeout: 30) do |http|
  puts http.get(uri.path).body
end

Session lifetime

A sticky session keeps its IP for up to 30 minutes. The time is set on the gateway and is the same for every customer.

  • After 30 minutes the session expires. The next connection with the same session ID can get a different IP.
  • Earlier drops can happen. Residential IPs are real home devices. If the device goes offline, the session loses its IP before the 30 minutes are up.
  • Need longer? Contact support about a custom session time.
!

Don't assume the IP stays for the full 30 minutes. Check the exit IP at important steps, like before a checkout, and be ready to start the flow again.

Get a new IP in sticky mode

Change the session ID. A new ID starts a new session with a new IP right away. There is no need to wait for the old one to expire.

UsernameResult
crh_USERNAME__cc_us__sid_job01IP A, kept for up to 30 minutes
crh_USERNAME__cc_us__sid_job01Same IP A
crh_USERNAME__cc_us__sid_job02New IP B
crh_USERNAME__cc_gb__sid_job01New IP C. A different location means a different session.

Handle a dropped session

If a sticky session starts returning 502, its IP has gone offline. Switch to a new session ID and continue.

Python
import secrets, requests

def new_proxies(country="us"):
    sid = secrets.token_hex(6)
    p = f"http://crh_USERNAME__cc_{country}__sid_{sid}:PASSWORD@proxy.crawlhub.ai:8000"
    return {"http": p, "https": p}

proxies = new_proxies()
try:
    r = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30)
except requests.exceptions.ProxyError:
    proxies = new_proxies()   # session dropped: start a new one
    r = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30)
print(r.json())

Best practices

  • Use one session ID per task, browser profile or account you manage.
  • Use random IDs (like a3f09c1b22de) so parallel workers never share a session by accident.
  • Keep multi-step flows under 30 minutes, or plan to start a new session partway.
  • Use rotating mode for one-off page fetches. It spreads load across more IPs.
Need help?Contact supportProxy checkerhello@crawlhub.ai
Copied