laravel-websockets/tests/Mocks
Fabian @ Blax Software ee04c8c731 BF refuse a broken app key or failed app lookup without stopping the server
Ratchet's router merges the query over the route parameters, so
/app/<anything>?appKey[]=x reached verifyAppKey() (and WebSocketsLogger's
onOpen when logging is on) with an array. QueryParameters::get(): string
threw a TypeError, onOpen only caught WebSocketException and Ratchet's
IoServer only catches \Exception, so the Error left the event loop and the
daemon exited. Anyone could do this before authenticating.

- QueryParameters::get() reads a non-string parameter as '', so the key
  becomes an unknown key: websocket.error 4001 and a closed socket.
- onOpen catches any other Throwable, logs it with the trace, sends
  websocket.error "Internal server error" (1011) and closes with 1011.
- verifyAppKey() settles the findByKey() promise in place instead of
  await(). await() on a pending promise would run the server's own loop
  again from a fiber inside onOpen. A rejected lookup is rethrown, a
  pending one is refused; the AppManager contract now says findByKey()
  must settle synchronously. ConfigAppManager already does.
- A refused connection (4001 unknown key, 4009 origin) closes with that
  code instead of 1000. 4000-4099 tells Pusher-style clients not to
  reconnect. ConnectionLogger::close() passes the code on.
- The refusal is logged at warning level without a trace, and the
  client-supplied key goes into the JSON-encoded context, not the log line.

Tests: the array key with and without the logger, QueryParameters on an
array, an app manager that rejects, one that never settles and one that
throws an Error, the close codes of the 4001/4009 refusals, and the server
test now checks the 4001 close code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 12:25:54 +01:00
..
Connection.php BF refuse a broken app key or failed app lookup without stopping the server 2026-11-04 12:25:54 +01:00
LazyClient.php Renovation 2025-01-16 08:54:02 +01:00
Message.php Renovation 2025-01-16 08:54:02 +01:00
PromiseResolver.php I stability 2026-03-21 12:56:50 +01:00
RedisFactory.php Renovation 2025-01-16 08:54:02 +01:00
SignedMessage.php Renovation 2025-01-16 08:54:02 +01:00