Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix-js-SDK MatrixError: [405] Unrecognized request #4174

Closed
maxine-96 opened this issue Apr 22, 2024 · 5 comments
Closed

Matrix-js-SDK MatrixError: [405] Unrecognized request #4174

maxine-96 opened this issue Apr 22, 2024 · 5 comments
Labels
X-Needs-Info This issue is blocked awaiting information from the reporter

Comments

@maxine-96
Copy link

Hey,
I am reaching out to seek assistance with an issue I am encountering while using the Matrix client.

The problem arises when I call the client.joinRoom(roomId) function. It seems that an additional "/?" is appended to the URL, causing the request to fail with a "405 Unrecognized request" error.

The client already exists and the credentials are set correctly. :)
SDK Version 32.0.0

Here are the relevant log entries:

DEBUG  FetchHttpApi: <-- POST ?? [92ms 405]
DEBUG  FetchHttpApi: <-- POST ?? [90ms 405]
ERROR  Error creating room: [M_UNRECOGNIZED: MatrixError: [405] Unrecognized request (https://my-matrix-server/_matrix/client/v3/createRoom/?)]
ERROR  Error joining room: [M_UNRECOGNIZED: MatrixError: [405] Unrecognized request (https://my-matrix-server/_matrix/client/v3/join/!ibNGtYzOqOyFMbTGaO%3Amy-matrix-server/?)]

My react native code:

  useEffect(() => {
    const initMatrixClient = async () => {
      try {
        const credentials = await getMatrixCredentials();
        const matrixClient = createClient({
          baseUrl: BASIC_MATRIX_URL,
          accessToken: credentials?.accessToken,
          deviceId: credentials?.deviceId,
          userId: credentials?.userId,
        });
        
        setClient(matrixClient);
      } catch (error) {
        console.log(error)
        throw new Error(error);
      }
    };

    initMatrixClient();

  }, []);

  useEffect(() => {
    if (client) {
      joinRoom(client)
    }
  }, [client]);

  

 async function joinRoom(client: MatrixClient): Promise<void> {
    console.log(client)
  try {
      await client.joinRoom(currentRoomId);
    } catch (error) {
      console.error(`Error: ${error}`);
    }
  }
@t3chguy
Copy link
Member

t3chguy commented Apr 22, 2024

I don't see anything in the code base that would append /?. I suggest sharing a minimum reproduction case rather than a subset of one. My guess is whatever fetch polyfill you are using is doing this.

@t3chguy t3chguy added the X-Needs-Info This issue is blocked awaiting information from the reporter label Apr 22, 2024
@t3chguy
Copy link
Member

t3chguy commented May 14, 2024

Closing due to lack of info

@t3chguy t3chguy closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@ghost
Copy link

ghost commented Aug 28, 2024

Actually I have the same problem - /? is appended to the end of every request which makes them to fail. I'm using react-native mobile app with matrix-js-sdk integrated with some polyfills. I guess I might need to check if those polyfills add /? somehow...

@ghost
Copy link

ghost commented Aug 28, 2024

Okay it turns out my client was not using react-native-url-polyfill, so after adding it and applying it by adding import 'react-native-url-polyfill/auto'; now it works :)

@ghost
Copy link

ghost commented Aug 28, 2024

@maxine-96 hopefully it helps ^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
X-Needs-Info This issue is blocked awaiting information from the reporter
Projects
None yet
Development

No branches or pull requests

2 participants