matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript
Apache License 2.0
1.54k stars 580 forks source link

Able to disable turn server check #1711

Open YousefED opened 3 years ago

YousefED commented 3 years ago

on startClient, the client will always do a network call to fetch turn servers. I'm using matrix-js-sdk in an environment where I'm not interested in Voip, so as a consumer it would be great to disable this functionatlity completely.

I see that there's a _supportsVoip member on Client, but the client always does a check and enables it if supported

demonking commented 1 year ago

i wanted to turn this off and went down the rabbithole

let client = sdk.createClient({
    baseUrl: server.baseUrl,
    canSupportVoip: false, // <-- this here
});

https://matrix-org.github.io/matrix-js-sdk/20.1.0/client.ts.html#line1051

image

src/webrtc/call.ts:2721

export function supportsMatrixCall(): boolean {
    // typeof prevents Node from erroring on an undefined reference
    if (typeof(window) === 'undefined' || typeof(document) === 'undefined') {
        // NB. We don't log here as apps try to create a call object as a test for
        // whether calls are supported, so we shouldn't fill the logs up.
        return false;
    }

    // Firefox throws on so little as accessing the RTCPeerConnection when operating in a secure mode.
    // There's some information at https://bugzilla.mozilla.org/show_bug.cgi?id=1542616 though the concern
    // is that the browser throwing a SecurityError will brick the client creation process.
    try {
        const supported = Boolean(
            window.RTCPeerConnection || window.RTCSessionDescription ||
            window.RTCIceCandidate || navigator.mediaDevices,
        );
        if (!supported) {
            /* istanbul ignore if */ // Adds a lot of noise to test runs, so disable logging there.
            if (process.env.NODE_ENV !== "test") {
                logger.error("WebRTC is not supported in this browser / environment");
            }
            return false;
        }
    } catch (e) {
        logger.error("Exception thrown when trying to access WebRTC", e);
        return false;
    }

    return true;
}

It is not possible to disable this function, because the specified value is always overwritten by the call..

t3chguy commented 1 year ago
canSupportVoip: false, // <-- this here

This is not a valid createClient option. canSupportVoip is a private member field on the client instance.

haardikk21 commented 1 year ago

+1 this would be great to be an option

bloor commented 10 months ago

+1

vavilov2212 commented 2 months ago

+1