• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

SimConnect Server send SIMCONNECT_RECV_ID_QUIT unexpectedly after connection established

Messages
10
Country
china
When p3d is starting(after connection to server established), it won't quit
After the Scenery Selection window appears or scenery completely loaded (when aircraft can be controlled), SIMCONNECT_RECV_ID_QUIT is sent
It even happens with the sample code provided in P3D sdk

It's really,really annoying and has exhausted me the whole afternoon trying to solve this
I would appreciate much if solution provided.
 
Are you using one of the samples in the SDK to test a connection? Also: enable SimConnect logging (see the SDK for instructions).
 
Last edited:
Are you using one of the samples in the SDK to test a connection? Also: enable SimConnect logging (see the SDK for instructions).
Hi,
Yes I'm using ClientEvent.cpp in the SDK. And I have already enabled SimConnect.(move 3 .xml files to C:\ProgramData\Lockheed Martin\Prepar3D v5). If I move SimConnect.ini to Documents\Prepar3D v5 files, I can see diagnostic console window outputting events even after quit=1 sent.

If I cout quit in each loop, a few 0 can be seen before 1. The number of 0 varies with how long do I Sleep after each loop. If I set Sleep(1), there will only be one 0, If that's 0.1, the number will be a lot more(but not 10).
 
Last edited:
The only time I have seen a constant disconnect from SimConnect was when I compiled a project linking to SimConnect.lib. Changing to SimConnectDebug.lib stopped the insta-quit signals, but I have no idea why. Is it possible to upload your code somewhere? Or can you create a sample that shows the behaviour?
 
The only time I have seen a constant disconnect from SimConnect was when I compiled a project linking to SimConnect.lib. Changing to SimConnectDebug.lib stopped the insta-quit signals, but I have no idea why. Is it possible to upload your code somewhere? Or can you create a sample that shows the behaviour?
This is my code. I've tried linking to SimConnectDebug.lib but it has no effect.
C++:
#pragma comment  (lib, "User32.lib")
#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "Ole32.lib")
#pragma comment(lib, "Shell32.lib")
#include <iostream>
#include <windows.h>
#include "SimConnect.h"
#include "KnownFolders.h"


int quit = 0;
HANDLE hsimconnect = NULL;

enum Event_ID
{
    EVENT_BREAK,
};

enum GROUP_ID
{
    GROUP0,
};

void CALLBACK MyDispatchProc1(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext)
{
    switch (pData->dwID)   //dwID is a member SIMCONNECT_RECV,representing the struct of data sent back
    {
    case SIMCONNECT_RECV_ID_EVENT:
    {
        SIMCONNECT_RECV_EVENT* evt = (SIMCONNECT_RECV_EVENT*)pData;     //Why can directly convert struct type?

        switch (evt->uEventID)
        {
        case EVENT_BREAK:
            printf("\nEvent brakes: %d", evt->dwData);
            break;

        default:
            break;
        }
        break;
    }


    case SIMCONNECT_RECV_ID_QUIT:
    {
        quit = 1;
        break;
    }

    default:
        break;
    }
}

void SimConnect_Detection()
{
    //keep connecting to the server until p3d on
    while (1)
    {
        if (SUCCEEDED(SimConnect_Open(&hsimconnect, "Client Event", NULL, 0, NULL, 0)))
        {
            break;
        }
    }
    std::cout << "Connected!" << std::endl;

    //monitor the event
    SimConnect_MapClientEventToSimEvent(hsimconnect, EVENT_BREAK, "brakes");
    SimConnect_AddClientEventToNotificationGroup(hsimconnect, GROUP0, EVENT_BREAK);
    SimConnect_SetNotificationGroupPriority(hsimconnect, 0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
    while (quit == 0)
    {
        SimConnect_CallDispatch(hsimconnect, MyDispatchProc1, NULL);
        std::cout << quit << std::endl;
        Sleep(1);
    }
    SimConnect_Close(hsimconnect);
}


int main()
{
    SimConnect_Detection();
    return 0;
}
 
I don't see where you've called SetInputGroupState to activate the input group itself.
 
Dude reads that gibberish like Latin. Tu scribes meas pro me Templates?
 
Rick: it's a straight copy'n'paste from a default Visual Studio 2022 setup. I'm not a fan of the default layout because (see above!) and always modify mine in the Options menu. As Ed says, there doesn't appear to be any group activation.
 
Yes thank you I understand, it's just the fluency you and Ed and some of the other guys on here have is inspiring to put it mildly.
 
Ah (!!!!!!) We're both wrong Ed - it doesn't need a SetInputGroupState to trigger things. I recognised the code as being a copy of the ClientEvent sample in the SDK, so I compiled the original to be sure that it worked, then copy/pasted CES5209's code in place of it. I removed the pragma lib calls, the cout calls and the link to known_folders.h and it works perfectly. The problem is somewhere else.
 
Ah (!!!!!!) We're both wrong Ed - it doesn't need a SetInputGroupState to trigger things. I recognised the code as being a copy of the ClientEvent sample in the SDK, so I compiled the original to be sure that it worked, then copy/pasted CES5209's code in place of it. I removed the pragma lib calls, the cout calls and the link to known_folders.h and it works perfectly. The problem is somewhere else.
I noticed that after I run my code, simconnect diagnostic output window shows "unrecognized client: receive data ignored" and then disconnected. What's the meaning of it?
 
That sounds like it could be a version mis-match somewhere. For example: the P3D v5 SDK will work with P3D v6, but the P3D v6 SDK may not work on P3D v5. In my experience it usually crashes, but that might just be the calls I was trying.
 
That sounds like it could be a version mis-match somewhere. For example: the P3D v5 SDK will work with P3D v6, but the P3D v6 SDK may not work on P3D v5. In my experience it usually crashes, but that might just be the calls I was trying.
oh my sdk version is 5.4 while p3d version is 5.3. Where can I download earlier versions of sdk?
 

From the website: "The SimConnect.lib and LockheedMartin.Prepar3D.SimConnect.dll provided in the SDK cannot be used to connect to FSX, ESP or any previous release of Prepar3D" so yes, it looks like we may have found your problem. Also, you should not need those pragma lib calls as those libraries should be called by default in Visual Studio.
 

From the website: "The SimConnect.lib and LockheedMartin.Prepar3D.SimConnect.dll provided in the SDK cannot be used to connect to FSX, ESP or any previous release of Prepar3D" so yes, it looks like we may have found your problem. Also, you should not need those pragma lib calls as those libraries should be called by default in Visual Studio.
thanks
 
Back
Top