diff --git a/src/@types/requests.ts b/src/@types/requests.ts index b985bec29..91ac85262 100644 --- a/src/@types/requests.ts +++ b/src/@types/requests.ts @@ -34,6 +34,7 @@ export interface IJoinRoomOpts { /** * The server names to try and join through in addition to those that are automatically chosen. + * Only the first 3 are actually used in the request, to avoid HTTP 414 Request-URI Too Long responses. */ viaServers?: string[]; @@ -71,6 +72,7 @@ export interface KnockRoomOpts { /** * The server names to try and knock through in addition to those that are automatically chosen. + * Only the first 3 are actually used in the request, to avoid HTTP 414 Request-URI Too Long responses. */ viaServers?: string | string[]; } diff --git a/src/client.ts b/src/client.ts index 52029ce47..654f42353 100644 --- a/src/client.ts +++ b/src/client.ts @@ -2391,8 +2391,8 @@ export class MatrixClient extends TypedEventEmitter1.11 (MSC4156) - queryParams.server_name = opts.viaServers; - queryParams.via = opts.viaServers; + // We only use the first 3 servers, to avoid URI length issues. + queryParams.via = queryParams.server_name = opts.viaServers.slice(0, 3); } const data: IJoinRequestBody = {}; @@ -2436,9 +2436,11 @@ export class MatrixClient extends TypedEventEmitter1.11 (MSC4156) - queryParams.server_name = opts.viaServers; - queryParams.via = opts.viaServers; + queryParams.server_name = viaServers; + queryParams.via = viaServers; } const body: Record = {};