# INVALID\_OPERATION: no audio joined while muting user

**URL:** <https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845>\
**Category:** Web\
**Created:** [February 9, 2023, 11:31am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845 "2023-02-09T11:31:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sprinklrqa4](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@sprinklrqa4](https://devforum.zoom.us/u/sprinklrqa4)\
**Post date:** [February 9, 2023, 11:31am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/1 "2023-02-09T11:31:38Z")

</div>

**Description**  
I have microphone permissions and I await startAudio after starting meeting. It unmutes the user. After that if I try to mute user, 1/10 times it gives me an error, INVALID\_OPERATION: no audio joined. How can I confirm if audio is joined before muting the user ?

**Browser Console Error**  
{type: ‘INVALID\_OPERATION’, reason: ‘no audio joined’}

**Which Web Video SDK version?**  
Video SDK- 1.5.5

**Video SDK Code Snippets**

```auto
const muteLocalTile = useCallback(async () => {
    try {
      await zmStream.current.muteAudio();
    } catch (e) {
     console.log(e)
    }
  }, []);

  const startAudio = useCallback(async () => {
    if (isSafari) {
      if (audioDecode.current && audioEncode.current) {
        await zmStream.current.startAudio();
        isAudioStarted.current = true;
      } else {
        logger.info('desktop safari audio init has not finished');
      }
    } else {
      await zmStream.current.startAudio();
      isAudioStarted.current = true;
    }
  }, [isSafari, logger]);

  const startMeeting = useCallback(
    async ({ meetingInfo }) => {
      try {
        await zmClient.current.join(meetingInfo.sessionName, meetingInfo.token, name, meetingInfo.passcode);
       } catch (error) {
          console.log(e) 
     }
      zmStream.current = zmClient.current.getMediaStream();
      if (!isSafari) {
        try {
          await startAudio();
        } catch (e) {
          console.error(e);
        }
      }
      await validateConfigOnMeetingInit();
      try {
        zmClient.current.getAllUser().forEach(user => {
          if (
            user.bVideoOn &&
            user.userId !== zmClient.current.getCurrentUserInfo().userId &&
            remoteCanvasRef.current
          ) {
            zmStream.current?.renderVideo(remoteCanvasRef.current, user.userId, 960, 540, 0, 0, 2);
          }
        });
      } catch (e) {
        console.error(e);
      }
    },
    [isSafari, name, startAudio, validateConfigOnMeetingInit]
  );

  const validateConfigOnMeetingInit = useCallback(async () => {    
    if (isAudioStarted.current && !micEnabled) {
      try {
        await muteLocalTile();
      } catch (e) {
        updateConfiguration({ type: ACTION_TYPES.UNMUTE });
      }
    }
  }, [updateConfiguration, muteLocalTile, micEnabled]);

```

**To Reproduce(If applicable)**  
The issue is intermittent, happens on starting a meeting with mute configuration.

**Screenshots**  
NA

**Troubleshooting Routes**  
NA

**Device (please complete the following information):**

- Device: MacBook Pro
- OS:12.2.1 (21D62)
- Browser: Safari
- Browser Version: 15.3 (17612.4.9.1.8)

**Additional context**  
sessionId: “bPNiByxHQFeUNViiCAAVJw==”  
participantId: 83887104

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [February 10, 2023, 9:05am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/2 "2023-02-10T09:05:54Z")

</div>

@sprinklrqa4 ,

Seems like there is a possibility out of the 1/10 times, the startAudio() has not completed yet.

An alternative implementation would be to use \* [event\_current\_audio\_change](https://marketplacefront.zoom.us/sdk/custom/web/modules.html#event_current_audio_change) to listen for users to successfully join audio before proceeding to mute them

---

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [February 28, 2023, 8:12am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/3 "2023-02-28T08:12:51Z")

</div>

Hi  
I have the same problem as the author of this topic.

According to the documentation, startAudio starts this way ( i.e. I need to wait for some events):

```auto
await client.init();
await client.join(topic, signature, username, password);
const stream = client.getMediaStream();
await stream.startAudio();

```

There is another version of the implementation for safari. I used to have it implemented this way, but problems began to arise with this method too:

```auto
// Safari browser is different:

let audioDecode, audioEncode;
// wait until the encoding and decoding process is ready for the audio
client.on("media-sdk-change", (payload) => {
   const { action, type, result } = payload;
   if (type === "audio" && result === "success") {
     if (action === "encode") {
       audioEncode = true;
     } else if (action === "decode") {
       audioDecode = true;
     }
     if (audioDecode && audioEncode) {
       try {
         // start audio automatically in Safari
         stream.startAudio({ autoStartAudioInSafari: true });
       } catch (err) {
         console.warn(err);
       }
     }
   }
 });

 // Start audio in 'click' callback in Safari
 joinAudioButton.addEventListener("click", () => {
   if (audioDecode && audioDecode) {
     try {
       stream.startAudio();
     } catch (err) {
        console.warn(err);
     }
   }
 });

```

But the problem with this method is that after disconnecting from the session and reconnecting, the necessary events (media-sdk-change) do not come, but only a part of them comes.

Each time the threads are initialized, 2 events (encoding and decoding) should occur in the session for each of the threads: audio, video, screen sharing. A total of 6 events should come, but when reconnecting to a session without reloading the page, only 4 come, and there are not even any events with audio data.

I tried both of these methods but could not find an optimal solution to this problem.  
In both cases, I wait for startAudio to execute and, upon successful completion, I call muteAudio:

```auto
await stream.startAudio();
await stream.muteAudio();

```

A participant on macbooks regularly 1/5 this problem. They just enter the conference and their microphone cannot be automatically muted.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/c/4c01523d478ba31ec6ed833a777c8df8d5e187d7.png)

**Web Video SDK 1.6.0**

---

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [February 28, 2023, 8:51am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/4 "2023-02-28T08:51:25Z")

</div>

@chunsiong.zoom, hi!  
My logs show that this trigger is triggered even before startAudio occurs. Are you sure this is how it should be?  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/0/6/065aa6f678dbe3d819969176f8c02df38a14ebf1.png)

In addition, I have tested the method you proposed, but the problem, unfortunately, remains =(

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [March 2, 2023, 8:40am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/5 "2023-03-02T08:40:13Z")

</div>

Hey @efron.vit @sprinklrqa4

Thanks for your feedback.

We will improve the timing of `startAudio` and `muteAudio` in the next version.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [March 9, 2023, 9:43am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/6 "2023-03-09T09:43:01Z")

</div>

Hi @vic.yang

Does this item in the changelog relate to this issue ?

> CHANGELOG v1.6.2
> 
> Enhanced
> 
> - Timing of the Promise resolve call returned by the `stream.startAudio` method

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [March 9, 2023, 11:26am UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/7 "2023-03-09T11:26:07Z")

</div>

Hey @efron.vit

Yes. We improved the timing of `stream.startAudio`. It’s the root cause of this issue.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 8, 2023, 9:26pm UTC](https://devforum.zoom.us/t/invalid-operation-no-audio-joined-while-muting-user/82845/8 "2023-04-08T21:26:15Z")

</div>

Closed on April 8, 2023, 9:26pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
