Commit Graph

15 Commits

Author SHA1 Message Date
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
Alexander Blasl 1a5db82c26 Renovation 2025-01-16 08:54:02 +01:00
Alex Renoki 97ab241fa3 Fixing PR #530 2020-09-16 11:02:58 +03:00
Alex Renoki ec47925c71 Added soft closes for connections on SIGTERM/SIGINT 2020-09-12 17:45:07 +03:00
Alex Renoki 6f32b89459 wip 2020-09-10 22:59:26 +03:00
Alex Renoki ca4a9a180e Running then() closures as block in tests 2020-09-05 22:40:52 +03:00
Alex Renoki e099c46a0d docblocks 2020-08-30 20:00:45 +03:00
Freek Van der Herten fa0bd1c9ef
Apply fixes from StyleCI (#329) 2020-03-04 10:58:39 +01:00
Marcel Pociot 9ce2cc3ff7
Apply fixes from StyleCI (#3) 2018-12-04 22:22:33 +01:00
Marcel Pociot 9c2ac54322 More tests 2018-12-03 10:21:35 +01:00
freek 6103f7ea1b add ping test 2018-11-28 23:59:58 +01:00
Marcel Pociot f4c356ba02 wip 2018-11-27 22:26:29 +01:00
freek 9fc7747b1d implement close on mock 2018-11-27 00:00:26 +01:00
Marcel Pociot 1e5b8994df wip 2018-11-26 00:20:18 +01:00
Marcel Pociot c822ea15a5 wip 2018-11-25 23:43:43 +01:00