Skip to content

Global Options

Sascha Greuel edited this page Aug 2, 2026 · 1 revision

Global options

Home · Performance · Troubleshooting

Global options apply to every server in one GameQ instance:

$gameQ
    ->setOption('timeout', 5)
    ->setOption('max_servers_per_batch', 25);

The legacy property syntax remains available, but setOption() is clearer for new code:

$gameQ->timeout = 5;

Options

Option Default Unit Purpose
debug false Rethrow handled query and protocol errors instead of converting the affected query to an offline result.
timeout 3 seconds Overall connection/query allowance passed to socket operations.
stream_timeout 200000 microseconds stream_select() polling interval while responses are collected.
write_wait 500 microseconds Pause between packet writes to reduce CPU and packet bursts.
max_servers_per_batch 50 servers Maximum number of servers processed concurrently in one batch. Values below one behave as one.
max_follow_up_rounds 64 rounds Safety limit for response-driven pagination and additional query rounds. Zero disables follow-up rounds.
capture_packets_file null path Write raw responses to a file for protocol fixture development.

Integer options accept integers and numeric strings. Other types raise InvalidArgumentException when the option is consumed. Use positive values for timeout and interval settings.

Debug mode

use GameQ\Exception\ProtocolException;
use GameQ\Exception\QueryException;

$gameQ->setOption('debug', true);

try {
    $results = $gameQ->process();
} catch (ProtocolException | QueryException $exception) {
    error_log($exception->getMessage());
}

Debug mode is intended for diagnosis and tests. Some validation and protocol-preparation failures necessarily bubble up regardless of this option, so production integrations should still handle GameQ exceptions around addServer() and process().

Do not display exception messages or packet data directly to untrusted users.

Packet capture

capture_packets_file supports the fixture-building workflow and is best used with one server at a time:

$gameQ
    ->setOption('debug', true)
    ->setOption('capture_packets_file', __DIR__ . '/response.bin');

The file can contain binary data, server metadata, player information, or protocol-specific secrets. Store it outside the web root, restrict its permissions, and inspect it before sharing. The fixture generator automates the normal test workflow.

Inspect configured values

$options = $gameQ->getOptions();
$servers = $gameQ->getServers();

Treat these as runtime configuration snapshots. Prefer documented setters to mutating internal objects.

Clone this wiki locally