flarum/framework · error · InvalidArgumentException
Paths are not possible in websocket connections.
Error message
Paths are not possible in websocket connections.
What it means
The realtime extension's daemonUrl() parses the daemon websocket URL and rejects URLs containing a path component, since websocket connections to the daemon go to host:port only; it throws InvalidArgumentException otherwise.
Solutions
- Remove the path from the configured URL, keeping scheme://host:port (e.g. wss://realtime.example.com).
- If a path is needed for proxies, handle path routing at the proxy level, not in the daemon URL config.
- Verify with parse_url semantics: anything after host/port (leading '/') is rejected.
Example fix
// before
(new Extend\Realtime())->daemonUrl('https://example.com/realtime')
// after
(new Extend\Realtime())->daemonUrl('https://realtime.example.com:8080') Defensive patterns
Strategy: validation
Validate before calling
$parsed = parse_url($url); if (! empty($parsed['path'])) { throw new InvalidArgumentException('daemon URL must not contain a path'); } Try / catch
try { $ext->daemonUrl($url); } catch (InvalidArgumentException $e) { /* strip path and retry */ } Prevention
- Configure only scheme://host:port for the realtime daemon
- Handle path routing at the reverse proxy, not in the URL
- Add a config linter that rejects URLs with path components
When it happens
Trigger: Configuring the realtime daemon URL with a path suffix, e.g. http://host:8080/socket or wss://example.com/realtime, when calling Extend\Realtime::daemonUrl() in the extension bootstrap.
Common situations: Copy-pasting a full app URL including a base path; assuming the daemon needs a route prefix; reverse-proxy setups where the public URL includes a path.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- Invalid auth signature provided.
- You cannot disable the default language pack!
- intervention/image: $driver is not valid
- Configuration file does not exist.
- Please specify a database driver.
AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15).
Data as JSON: /api/errors/782b991bddf5f3e2.
Report an issue: GitHub.
Appendix: source
Thrown at extensions/realtime/src/Extend/Realtime.php:103
// -------------------------------------------------------------------------
// Server configuration
// -------------------------------------------------------------------------
/**
* Provide the full url to the running `php flarum realtime:serve` daemon.
* In case you proxy it, use the outside URL.
*
* @example https://wss.flarum.site
* @example https://flarum.site:9001
*
* @see `php flarum realtime:serve --help`
*/
public function daemonUrl(string $url): self
{
$parsed = parse_url($url);
if (! empty($parsed['path'])) {
throw new InvalidArgumentException('Paths are not possible in websocket connections.');
}
$this->configuration['php-client-secure'] = ($parsed['scheme'] ?? 'http') === 'https';
$this->configuration['php-client-host'] = $parsed['host'] ?? '';
$this->configuration['php-client-port'] = $parsed['port'] ?? null;
$this->configuration['js-client-secure'] = ($parsed['scheme'] ?? 'http') === 'https';
$this->configuration['js-client-host'] = $parsed['host'] ?? '';
$this->configuration['js-client-port'] = $parsed['port'] ?? null;
return $this;
}
/**
* Set maximum number of allowed websocket connections.
*/
public function maxConnections(int $connections): self
{View on GitHub (pinned to 4b939f6853)