# Exception on Message Loop

**URL:** <https://devforum.zoom.us/t/exception-on-message-loop/66586>\
**Category:** Windows\
**Created:** [March 28, 2022, 8:31pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586 "2022-03-28T20:31:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadu\_cemo](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kadu\_cemo](https://devforum.zoom.us/u/kadu_cemo)\
**Post date:** [March 28, 2022, 8:31pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/1 "2022-03-28T20:31:37Z")

</div>

**Description**

**Hi Community!**

First of all… I´m really new on Zoom´s universe, so forgive me if my doubt seems foolish…  
I was following the Getting Started tutorial to make a simple console application. But, just as I´ve started I began to have issues… Well… I´ve created those callbacks, and it seems to work well, but as my application continues to run it throws an exception that I’ve been struggling with. It seems that an object is out of context, but I don´t know why… Can anyone help me on this issue?

My code follows in [TestZoomVideoSDK\_Console](https://github.com/kaducemo/TestZoomSDKConsole)

Thank you!

**Which Windows Video SDK version?**  
Video SDK version 1.2.2

Steps to reproduce the behavior:  
Execute my code with a valid JWT. The exception will be generated on the message loop…

**Screenshots**

 ![Exception](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/7/4/74a660f8b3b2d4bd0e03fc8cd24d9995673ad359.png)  
[https://ibb.co/RBTJhrL](https://ibb.co/RBTJhrL)

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

- Device: [Dell Inspiron]
- OS: [Windows 10]

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [March 29, 2022, 4:56pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/2 "2022-03-29T16:56:49Z")

</div>

Hi @kadu_cemo, thanks for using our SDK.

Can you please provide the steps to reproduce this crash so that we can investigate further? Also, is this reproducible on v1.2.3 of the SDK?

Thanks!

---

<div class="post-metadata">

**Author:** ![kadu\_cemo](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kadu\_cemo](https://devforum.zoom.us/u/kadu_cemo)\
**Post date:** [March 29, 2022, 5:36pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/3 "2022-03-29T17:36:19Z")

</div>

Hi jon.lieblich!

Thanks for your reply…

> [@kadu\_cemo](#):
>
> **Steps to reproduce the behavior:**
> 
> 1. Load the my project on Visual Studio (the link it is in the message I´ve sent before)
> 2. Use your own info to get a JWT at [jwt.io](http://jwt.io)
> 3. In file **TestConsole\_ZoomVideoSDK.cpp** there is a variable(sessionContext). Use the info that you used to generate the JWT to pass to that variable… So in my case…
> 
> ```auto
> //Session Context configuration
> sessionContext.sessionName = L"Sessao";    
> sessionContext.userName = L"Kadu";
> // JWT for this session.
> sessionContext.token = L"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBfa2V5IjoianlGMDlRZkxHNW83N2N6Zm9HTU4xbmxtTzQyYVRqN0xTNkFuIiwidmVyc2lvbiI6MSwicm9sZV90eXBlIjoxLCJ1c2VyX2lkZW50aXR5IjoiS2FkdSIsInNlc3Npb25fa2V5IjoiU2Vzc2FvIiwiaWF0IjoxNjQ4NDc0MDI4LCJleHAiOjE2NDg2NDY4MjgsInRwYyI6IlNlc3NhbyJ9.XUc9otCgOsBXjwZJbSrTphD_n36lwMcWg-O9iDJmpOg";
> // Video and audio options.
> sessionContext.videoOption.localVideoOn = true;
> sessionContext.audioOption.connect = true;
> sessionContext.audioOption.mute = false;
> 
> ```
> 
> 1. Just run the code.
> 
> You will see that it will run and you will see in the Console that it could create and enter a Session, but next it will throw an exception.
> 
> I´ve been wandering if the exception is ocurring because I´ve didn´t include the Video Renderer library yet. So I didnt set a callback to video data… 🤔
> 
> Thank you again for your reply…

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [March 30, 2022, 6:50pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/4 "2022-03-30T18:50:38Z")

</div>

Hi @kadu_cemo,

I’m not seeing any issues with the fields you’re setting on `sessionContext`, but the error you’re seeing is unlikely to be related to these values in particular. Can you provide some additional context around how you’re using the SDK in your project, including how `sessionContext` is being defined, where you’re setting the `IZoomVideoSDKDelegate`, calling `joinSession`, etc.?

Thanks!

---

<div class="post-metadata">

**Author:** ![kadu\_cemo](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kadu\_cemo](https://devforum.zoom.us/u/kadu_cemo)\
**Post date:** [March 30, 2022, 8:27pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/5 "2022-03-30T20:27:05Z")

</div>

**Hi Jon,**

I´m running just a console application. Follows some code in the main file…

```auto
/*Globals*/
IZoomVideoSDK* m_pVideoSDK;
MyListeners myListeners;
IZoomVideoSDKSession* pSession;
ZoomVideoSDKSessionContext sessionContext;
ZoomVideoSDKInitParams initParams;

int main()
{    

    m_pVideoSDK = CreateZoomVideoSDKObj();    
       
    initParams.domain = L"https://zoom.us";    
    initParams.audioRawDataMemoryMode = ZoomVideoSDKRawDataMemoryModeStack;
    initParams.videoRawDataMemoryMode = ZoomVideoSDKRawDataMemoryModeStack;
    initParams.shareRawDataMemoryMode = ZoomVideoSDKRawDataMemoryModeStack;    
    initParams.enableIndirectRawdata = false;    
    initParams.enableLog = true;    
    initParams.logFilePrefix = L"prefix";

    ZoomVideoSDKErrors returnVal = m_pVideoSDK->initialize(initParams);
    if (returnVal != ZoomVideoSDKErrors_Success) //Error...   
        return returnVal;      
    
    cout << "SDK Instance created...\n";

    myListeners = MyListeners(m_pVideoSDK);

    cout << "Listeners created and passed to SDK instance...\n"; //Listeners Criadados e passados para a SDK

    //Session Context configuration
    sessionContext.sessionName = L"Sessao";    
    sessionContext.userName = L"Kadu";
    // JWT for this session.
    sessionContext.token = L"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBfa2V5IjoianlGMDlRZkxHNW83N2N6Zm9HTU4xbmxtTzQyYVRqN0xTNkFuIiwidmVyc2lvbiI6MSwicm9sZV90eXBlIjoxLCJ1c2VyX2lkZW50aXR5IjoiS2FkdSIsImlhdCI6MTY0ODY2MzU5NywiZXhwIjoxNjQ4ODM2Mzk3LCJ0cGMiOiJTZXNzYW8ifQ.-VKI5KpdRQSWEfjbxgcaP-RL0w2lVn3KrGRDN6mHnhY";
    // Video and audio options.

    sessionContext.videoOption.localVideoOn = true;
    sessionContext.audioOption.connect = true;
    sessionContext.audioOption.mute = false;

    pSession = m_pVideoSDK->joinSession(sessionContext);

    if (!pSession)
    {
        CString cstrInfo;
        cstrInfo.Format(_T("Failed to join session"));
    }

    else
    {
        CString cstrInfo;
        cstrInfo.Format(_T("Joined session successfully."));
    }

    //Message Loop...
    bool bRet = false;
    MSG msg;
    while ((bRet = GetMessage(&msg, nullptr, 0, 0)) != 0)
    {
        if (bRet == -1)
        {
            // handle the error and possibly exit
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
}

```

As you can see everything was setup in the main function…  
But now I have an update… When I commented out

```auto
myListeners = MyListeners(m_pVideoSDK);

```

The error stops throwing… Maybe I´m doing something wrong setting up my listener object…

Thank you for your reply!

---

<div class="post-metadata">

**Author:** ![kadu\_cemo](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kadu\_cemo](https://devforum.zoom.us/u/kadu_cemo)\
**Post date:** [April 1, 2022, 1:57pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/6 "2022-04-01T13:57:35Z")

</div>

**Well…**

As I´ve invetigated until here… The error is really happening inside my listener. Actually it is happening in the callback **onUserVideoStatusChanged** in the commented statement in the following code:

```auto
void MyListeners::onUserVideoStatusChanged(IZoomVideoSDKVideoHelper* pVideoHelper, IVideoSDKVector<IZoomVideoSDKUser*>* userList)
{
    CString strInfo;
    IZoomVideoSDKUser* pUser;
    int count = userList->GetCount();

    for (int i = 0; i < count; i++)
    {
        pUser = userList->GetItem(i);
        //strInfo.Format(_T("A user's video status changed: userid=%s, name=%s, status=%s"), pUser->getUserName(), pUser->getVideoStatus());
    }
}

```

I still don´t know why this code line is crashing my app… But I´m really close to find out.  
This code was actually copied from the getting started tutorial, so I hope this can help someone in future.

---

<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:** [May 1, 2022, 11:58pm UTC](https://devforum.zoom.us/t/exception-on-message-loop/66586/7 "2022-05-01T23:58:02Z")

</div>

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