# How to reset connection?

**URL:** <https://devforum.zoom.us/t/how-to-reset-connection/40510>\
**Category:** Web\
**Created:** [January 14, 2021, 5:12am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510 "2021-01-14T05:12:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony1905](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@Tony1905](https://devforum.zoom.us/u/Tony1905)\
**Post date:** [January 14, 2021, 5:12am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/1 "2021-01-14T05:12:17Z")

</div>

**Description**  
I’m using react to create a component which integrate with zoom sdk.  
It works ok if every time I refresh my browser but if I use react-router-dom to go to another component and go back to this component, it throw an error when joining  
**Error**  
reason: “duplicated operation”  
type: “INVALID\_OPERATION”

**Which version?**  
Latest version Fully customisable sdk

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

1. From my app container go to the component where calling zoom sdk join, it works fine for the first time.
2. Go to another screen (using react-router-dom)
3. Go back to screen where is using zoom sdk, it throw an error when calling client.join  
**Screenshots**  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/6/5692a8184d5565e95fe4b04d8dda10018d2ae78f.png)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/4/54ea55467910dd069db488498a3508f9aa62eadc.png)

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

**Additional context**  
Add any other context about the problem here.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [January 14, 2021, 6:34pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/2 "2021-01-14T18:34:49Z")

</div>

Hey @Tony1905 ,

Thanks for reporting this, I have shared this with our SDK Engineers. (CS-2829) I will get back to you with how to fix it, or if we need to fix something on our end. 🙂

-Tommy

---

<div class="post-metadata">

**Author:** ![diginikkari](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/diginikkari/32/24552_2.png) [@diginikkari](https://devforum.zoom.us/u/diginikkari)\
**Post date:** [April 8, 2021, 10:22am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/3 "2021-04-08T10:22:58Z")

</div>

Hey @tommy,

was there any solution for this? I have the same issue. After leaving session with client.leave() I’m not able to join again. First I get following error when after.calling client.leave():  
`index.esm.js:formatted:1 WebSocket is already in CLOSING or CLOSED state.`

Then when trying to join. I get `duplicated operation` error from react.

-Timo-

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 9, 2021, 5:17pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/4 "2021-04-09T17:17:04Z")

</div>

Hey @diginikkari ,

Sorry to hear you are facing this issue. I should have an update for you soon on a solution. 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 9, 2021, 9:20pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/5 "2021-04-09T21:20:12Z")

</div>

Hey @diginikkari ,

We recommend you return a clickable button or similar, that would call client.leave if the user client has actually successfully joined/initialized. You can ensure you only call client.leave by using react’s built-in state functionality and a boolean following Zoom client connection/disconnection. Besides that, you could make the call event-based instead of component-based like this. At minimum, if you want to keep it as-is, you should track/maintain the zoom client’s connection state on you own end to make sure duplicate calls aren’t made.

Let me know if that helps! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![diginikkari](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/diginikkari/32/24552_2.png) [@diginikkari](https://devforum.zoom.us/u/diginikkari)\
**Post date:** [April 10, 2021, 10:32am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/6 "2021-04-10T10:32:05Z")

</div>

Hi Tommy,

infact that is what I’m currently doing. I have state with my topic setup and I have useEffect where I’m checking it:

```
const session = client?.getSessionInfo();    
if (!roomSetup && session?.isInMeeting) {
      client.leave()
        .then(() => console.log('Leaved session succesfully'))
        .catch((e) => console.error('leave session errored', e));
}

```

I’m still getting 4 error messages:  
`WebSocket is already in CLOSING or CLOSED state.`

This promise is resolved successfully but there is no ‘connection-change’ event received.

When I’m trying to join new meeting by calling client.join(). This promise is rejected with ‘duplicated operation’ error. So it seems like connection is not closed correctly and is left in some error state. This could be related to [Calling client.leave() to end session is not triggering the client connection-change event](https://devforum.zoom.us/t/calling-client-leave-to-end-session-is-not-triggering-the-client-connection-change-event/46478). Is there something else that I should do after client.leave() before I’m joining again?

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 12, 2021, 4:26pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/7 "2021-04-12T16:26:56Z")

</div>

Thanks for confirming @diginikkari .

We are looking into the 4 errors you are getting and will follow up if we need more details or once we find the root cause.

-Tommy

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 12, 2021, 8:18pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/8 "2021-04-12T20:18:10Z")

</div>

Hey @diginikkari ,

Update, please see @vic.yang , answer here:

> [@How to reset connection?](https://devforum.zoom.us/t/how-to-reset-connection/40510/9):
>
> Due to the client instance created by ZoomInstant.createClient() is a singleton, if you want to reset the connection, you should invoke ZoomInstant.destroyClient() and ZoomInstant.createClient() methods to recreate an instance. Hope this will help you.

~~After speaking with our engineers, we suggest the following:~~

~~First, you can poll client.getSessionInfo() with at a regular interval (not recommended); second, you can use a state variable:~~

~~[isInMeetingSession, setIsInMeetingSession] = useState(false)~~

~~When client.leave() resolves, call setIsInMeetingSession(false) and have a useEffect for isInMeetingSession that checks for its value changing to false. You can and should enable the client.join() logic inside this effect. This creates a “callback” effect that you can listen and respond to, and alleviates the need for a connection-change event~~

Thanks,  
Tommy

---

<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:** [April 13, 2021, 8:48am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/9 "2021-04-13T08:48:10Z")

</div>

Due to the `client` instance created by `ZoomInstant.createClient()` is a singleton, if you want to reset the connection, you should invoke `ZoomInstant.destroyClient()` and `ZoomInstant.createClient()` methods to recreate an instance. Hope this will help you.

---

<div class="post-metadata">

**Author:** ![martinkruusement](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/martinkruusement/32/26322_2.png) [@martinkruusement](https://devforum.zoom.us/u/martinkruusement)\
**Post date:** [April 25, 2021, 4:17am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/10 "2021-04-25T04:17:42Z")

</div>

Can you confirm that this is working in the current downloadable version?  
1.0.2 in version.txt / 1.0.0 package.json

If so, can you provide a very basic vanilla javascript example?

So far I have not found any working way to call Client.join() twice without fully reloading the page, no matter how many times ZoomInstant.destroyClient is called and re-initalized.

The idea is to connect to one session, disconnect from it and connect to a different session.

---

<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:** [April 25, 2021, 6:37am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/11 "2021-04-25T06:37:02Z")

</div>

Hey @martinkruusement,

Sorry for the bad experience with Video SDK, we will release a hotfix version(1.0.3) to solve this issue in the next few days.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![bekit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bekit/32/26056_2.png) [@bekit](https://devforum.zoom.us/u/bekit)\
**Post date:** [April 26, 2021, 5:36pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/12 "2021-04-26T17:36:53Z")

</div>

Sounds like they are already aware of this issue. I can confirm that I see it as well. Even with `destroyClient`, I can’t recreate a connection with `createClient`. The only way I’ve found to reset a connection is a full `window.location.reload()`, and that’s obviously not ideal 🙂

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 27, 2021, 6:50pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/13 "2021-04-27T18:50:35Z")

</div>

Correct @bekit , we are working to fix this in version 1.0.3 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![bekit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bekit/32/26056_2.png) [@bekit](https://devforum.zoom.us/u/bekit)\
**Post date:** [April 27, 2021, 7:03pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/14 "2021-04-27T19:03:20Z")

</div>

Good to know! Is there any ETA for the new update?

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 28, 2021, 5:28pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/15 "2021-04-28T17:28:08Z")

</div>

Hey @bekit , @martinkruusement , @diginikkari , @Tony1905 ,

This was fixed in the latest 1.0.3 release. Details here:

> [@Video SDK Web version 1.0.3](https://devforum.zoom.us/t/video-sdk-web-version-1-0-3/49113):
>
> Video SDK Web version 1.0.3 Hello Zoom Developers, here are the updates for the Video SDK Web version 1.0.3 release : Added Single View, a solution to present videos on browsers that are not capable of rendering multiple videos. For example, Firefox and Safari. The stream.isSupportMultipleVideos method. This method returns “yes” if the browser is capable of rendering multiple videos. Support share screen on Safari v14.0.3. The webEndpoint argument to init . Use if you want to use vanity URLs o…

Please download the latest version from the marketplace to get the updates. 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![bekit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bekit/32/26056_2.png) [@bekit](https://devforum.zoom.us/u/bekit)\
**Post date:** [April 29, 2021, 12:05am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/16 "2021-04-29T00:05:58Z")

</div>

FWIW, I’m still running into issues with this. After doing a `leave` call, I’m finding that I have to completely tear down my canvas and build a new one before joining or else I run into issues when rendering to it. I’m also having issues with getting my local camera to re-render if any other user is already rendered after leaving & re-joining. It seems to be some sort of a timing issue - if I delay starting to render my local camera by a couple of seconds, it will work fine.

This may still be issues with my code, but I wanted to mention my experience in case any one else is trying this and running into the same problems.

---

<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:** [April 29, 2021, 3:06am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/17 "2021-04-29T03:06:21Z")

</div>

Hey @bekit  
Thanks for sharing your experience with Video SDK.

The first issue:

> After doing a `leave` call, I’m finding that I have to completely tear down my canvas and build a new one before joining or else I run into issues when rendering to it.

Yes. In Video SDK, the canvas will be transferred to `OffscreenCanvas` if the platform supports this feature, thus you will lose control of canvas in the main thread, and the canvas can not be transferred twice. During the session, Video SDK will track the state of canvas, but once leave the session, all the state will be cleared to avoid state conflicts with the next session. So we advise when rejoining the session, you can add a loading page to replace the current module before the session is connected, and then rendering DOM Element.

The second one:

> I’m also having issues with getting my local camera to re-render if any other user is already rendered after leaving & re-joining. It seems to be some sort of a timing issue - if I delay starting to render my local camera by a couple of seconds, it will work fine.

Could you please provide a detailed scenario? Or sample code to help us troubleshoot this issue?

---

<div class="post-metadata">

**Author:** ![hellonobug9](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/hellonobug9/32/19285_2.png) [@hellonobug9](https://devforum.zoom.us/u/hellonobug9)\
**Post date:** [May 17, 2021, 3:17am UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/18 "2021-05-17T03:17:28Z")

</div>

Hello @tommy, how can I upgrade to 1.0.3 version?  
if I have an account I can download it ?

Many thanks!!

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [May 17, 2021, 3:19pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/19 "2021-05-17T15:19:41Z")

</div>

Hey @hellonobug9 ,

Yes, you can download the latest version from your [Video SDK app](https://marketplace.zoom.us/docs/sdk/video/web). 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [May 17, 2021, 3:19pm UTC](https://devforum.zoom.us/t/how-to-reset-connection/40510/20 "2021-05-17T15:19:47Z")

</div>


