Can not join meeting when windows load

Description
Here is my code
$(document).ready(function() {
console.log(‘checkSystemRequirements’);
console.log(JSON.stringify(ZoomMtg.checkSystemRequirements()));
ZoomMtg.setZoomJSLib(‘https://source.zoom.us/1.7.2/lib’, ‘/av’);
ZoomMtg.preLoadWasm();
ZoomMtg.prepareJssdk();

            ZoomMtg.init({
                leaveUrl: 'http://www.zoom.us',
                isSupportAV: true,
                success: function () {
                    ZoomMtg.join({
                        meetingNumber: '@meetingNumber',
                        userName: '@userName',
                        signature: '@signature',
                        apiKey: '@apiKey',
                        userEmail: 'email@gmail.com',
                        passWord: '@passWord',
                        success: function(res) {
                            $('#nav-tool').hide();
                            console.log('join meeting success');
                        },
                        error: function(res) {
                            console.log(res);
                        }
                    });
                },
                error: function (res) {
                
                    console.log(res);
                }
            });

    });

Error
I customize the sample code, i want to join meeting onload but always nothing happen?
If i using button click it always message “fail to join”
I code on MVC c# so @meetingNumber value from a viewbag
What Error is here?
Thank for read :slight_smile:

Hey @tranvuong1803,

How are you generating the signature? Also what is the meeting ID you are trying to join?

Thanks,
Tommy

Thank @tommy to answer my question
I use these code to generate signature,
The meeting id 9129153552 i created from API, i can join this meeting by join url zoom.us/j/9129153552&pwd

static readonly char[] padding = { '=' };

        static void Main (string[] args) {
            Console.WriteLine ("Zoom copyright!");
            Console.WriteLine ("generate websdk token!");
            string apiKey = "apiKey";
            string apiSecret = "apiSecret";
            string meetingNumber = "";
            String ts = ToTimestamp(DateTime.UtcNow.ToUniversalTime ()).ToString();
            string role = "1";
            string token = GenerateToken (apiKey, apiSecret, meetingNumber, ts, role);
            Console.WriteLine (token);
        }

        public static long ToTimestamp (DateTime value) {
            long epoch = (value.Ticks - 621355968000000000) / 10000;
            return epoch;
        }

        public static string GenerateToken (string apiKey, string apiSecret, string meetingNumber, string ts, string role) {
            string message = String.Format ("{0}{1}{2}{3}", apiKey, meetingNumber, ts, role);
            apiSecret = apiSecret ?? "";
            var encoding = new System.Text.ASCIIEncoding ();
            byte[] keyByte = encoding.GetBytes (apiSecret);
            byte[] messageBytesTest = encoding.GetBytes (message);
            string msgHashPreHmac = System.Convert.ToBase64String (messageBytesTest);
            byte[] messageBytes = encoding.GetBytes (msgHashPreHmac);
            using (var hmacsha256 = new HMACSHA256 (keyByte)) {
                byte[] hashmessage = hmacsha256.ComputeHash (messageBytes);
                string msgHash = System.Convert.ToBase64String (hashmessage);
                string token = String.Format ("{0}.{1}.{2}.{3}.{4}", apiKey, meetingNumber, ts, role, msgHash);
                var tokenBytes = System.Text.Encoding.UTF8.GetBytes (token);
                return System.Convert.ToBase64String (tokenBytes).TrimEnd (padding);
            }
        }

@tommy i findout that function generate signature C# error, i try generate with javascript is okie

what did i do to generate right signature from c#

Signature
Generate from javascript:
Ty1hc1RyWDNUcGUxNVFRamRBel9uZy45MTI5MTUzNTUyLjE1ODUwMzA5NjM5NzIuMC53NWpCeWRRVzAwaXh4L3VCWFZURWRHTXdrUlFScFgxZG5vRlZjVkw5VHZBPQ
Generate from serverside: Ty1hc1RyWDNUcGUxNVFRamRBel9uZy45MTI5MTUzNTUyLjE1ODUwNTYxNzI0MjEuMC45c3A4akRIcXBwZWppU21FZkhVbStiazlHcXF6RGJ2V21STnd6WExlU3FBPQ

Hey @tranvuong1803,

They both appear correct, but maybe there is a bug in the c# example.

Here is a Node.js signature sample app you could use in the meantime:

https://marketplace.zoom.us/docs/sdk/native-sdks/web/essential/signature#simple-signature-setup

Related thread:

Thanks,
Tommy

1 Like

try
string ts = ToTimestamp(DateTime.UtcNow.ToUniversalTime()).ToString();
change to
String ts = ToTimestamp(DateTime.UtcNow.ToUniversalTime() - 30000).ToString();

if your sever go ahead zoom server, it will casue signature expired issue

and try syc your server time

2 Likes

thank, i will try it

hey Jack, can not subtract datetime and int?
“DateTime.UtcNow.ToUniversalTime() - 30000” is that right?

sorry make mistake,

String ts = (ToTimestamp(DateTime.UtcNow.ToUniversalTime ()) - 30000).ToString();

3 Likes

Hi, I had written Jquery customize. I found one error . That is
“Uncaught ReferenceError: ZoomMtg is not defined”

how can i define ZoomMtg ?

This is my code

$(document).ready(function () {

    console.log('checkSystemRequirements');
    console.log(JSON.stringify(ZoomMtg.checkSystemRequirements()));
    ZoomMtg.setZoomJSLib('https://source.zoom.us/1.7.2/lib', '/av');
    ZoomMtg.preLoadWasm();
    ZoomMtg.prepareJssdk();     

Thanks

Hey @manishkumarmm93,

Have you added the script in your index.html so ZoomMtg is globally available?

Thanks,
Tommy