Skip to main content
This example demonstrates a real-world pattern: checking the same URL from multiple countries in parallel, collecting structured results, and handling failures gracefully. It’s designed as a starting point for price monitoring, ad verification, or geo-targeted data collection. The program uses a worker pool where each worker gets its own session and country assignment. Workers retry on failure with exponential backoff, and the entire job can be cancelled with a context timeout.

What this example covers

  • Configurable worker pool with controlled concurrency
  • One session per country (consistent IP per geo)
  • Structured result collection across all workers
  • Exponential backoff retry on failure
  • Context-based timeout and graceful shutdown
  • Clean separation between configuration, execution, and output

Full code

How to run it

Set your package key as an environment variable:

Example output

How it works

Worker pool. The MaxConcurrency setting controls how many countries are checked at the same time. With 10 countries and 5 workers, the job runs in two waves. Increase concurrency to run all countries simultaneously, or decrease it to stay within your package’s connection limits. One session per country. Each country gets a session ID (geo_us, geo_gb, etc.). This means the same IP is reused if you run the job multiple times within the session’s 60-second inactivity window. For monitoring jobs that run on a schedule, this gives you consistent IPs across runs. Exponential backoff. If a request fails, the worker waits before retrying: 500ms after the first failure, 1s after the second, 2s after the third. This avoids hammering the proxy during transient issues. Context timeout. The entire job has a 30-second deadline. If any worker is still running when the timeout hits, it gets cancelled and returns a clear error. This prevents hung requests from blocking your pipeline. Structured results. Every result includes the country, exit IP, ISP, response timing, retry count, and any errors. This makes it easy to pipe into a database, alerting system, or dashboard.

Adapting this for your use case

Change the target URL. Replace checker.soax.com/api/ipinfo with the URL you’re monitoring. The result struct will need updating to match your target’s response format. Add more countries. The Countries slice controls which geos are checked. Add or remove country codes as needed. Switch to mobile. Change the proxy string to include network-mob:
Add rotation. If you want a fresh IP on every run instead of reusing sessions, remove the session parameter from the proxy string, or append a timestamp to the session ID to force a new session each time:
Write results to a file. Replace the fmt.Println at the end with a file write for scheduled jobs:

Next steps

Residential proxies

Full parameter reference for session, rotation, and error handling options.

Go examples

Simpler Go examples for getting started.

Error codes

Understand what errors mean and how to handle them in your code.

Connection debugging

Troubleshoot timeouts, auth failures, and geo mismatches.