zoom / videosdk-ui-toolkit-web

The Zoom Video SDK UI toolkit is a prebuilt video chat user interface powered by the Zoom Video SDK.
https://www.npmjs.com/package/@zoom/videosdk-ui-toolkit
Other
8 stars 6 forks source link

Different errors after update #20

Open alexnechifor opened 1 month ago

alexnechifor commented 1 month ago

Hello! After updating zoom-video-sdk to latest version, a coleague of mine keeps getting some errors from time to time (not always) from UI Toolkit.

For example:

I'm wondering if it is something wrong with my approch:

const { user } = useContext(UserContext);
  const [config, setConfig] = useState<ConfigInterface | null>(null);
  const containerRef = useRef<HTMLDivElement | null>(null);
  const { setIsNotificationActionBlocked } = useContext(NotificationsContext);

  useEffect(() => {
    if (!videoSessionId || !user || !containerRef.current) return;

    const init = async () => {
      setIsNotificationActionBlocked(true);
      const jwt = await getZoomToken({
        role: user.profile_butler ? 1 : 0,
        sessionName: videoSessionId,
        expirationSeconds: 1800,
        userIdentity: user.profile_device
          ? user.profile_device.id
          : user.profile_butler!.id,
        sessionKey: videoSessionId,
      });

      const predefinedConfig = {
        videoSDKJWT: jwt,
        sessionName: videoSessionId,
        userName: user.name,
        sessionPasscode: "",
        role: user.profile_x ? 1 : 0,
        sessionKey: videoSessionId,
        features: ["video", "audio"],
      };

      setConfig(predefinedConfig);
    };

    init();
    return () => {
      setIsNotificationActionBlocked(false);
    };
  }, [videoSessionId, user, handleCloseCall, setIsNotificationActionBlocked]);

  useEffect(() => {
    const container = containerRef.current;
    if (container && config) {
      uitoolkit.joinSession(container, config);
      uitoolkit.onSessionClosed(handleCloseCall);
    }

    return () => {
      if (container) {
        try {
          uitoolkit.closeSession(container);
        } catch (error) {
          console.error("Failed to close session:", error);
        }
      }
      uitoolkit.offSessionClosed(handleCloseCall);
    };
  }, [config, handleCloseCall]);

  return (
    <div className="flex flex-col items-center justify-center gap-10">
      <div id="sessionContainer" className="w-2/4" ref={containerRef}></div>{" "}
    </div>
  );

Thanks!

tommygaessler commented 1 month ago

Hey @alexnechifor, it seems to be a bad network connection or perhaps your network is blocking the Zoom real time media servers?

https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0060548