Connection Issues
Network connectivity problems can prevent successful API requests.
Symptoms¶
- Error messages like "connection timeout," "failed to connect," or "network error"
- Long delays before errors appear
Solutions¶
-
Check Internet Connection: Ensure your server has a stable internet connection
-
Verify API Endpoint: Make sure the API endpoint URL is correct
-
Proxy Settings: If you're behind a proxy, configure it properly
// Using custom HTTP client with proxy settings
use Cognesy\Http\Config\HttpClientConfig;use Cognesy\Http\HttpClient;
$config = new HttpClientConfig(
requestTimeout: 30,
connectTimeout: 10,
additionalOptions: ['proxy' => 'http://proxy.example.com:8080']
);
$httpClient = new HttpClient('guzzle', $config);
$inference = new Inference();
$inference->withHttpClient($httpClient);
-
Firewall Rules: Check if your firewall is blocking outgoing connections to API endpoints
-
DNS Resolution: Ensure your DNS is resolving the API domains correctly