aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

Not receiving event callbacks from LexRuntimeV2Client::StartConversation

Open ryan-motive opened this issue 3 years ago • 7 comments

Describe the bug

After a successful call to PutSession, I'm using the following code to start conversation streaming:

` LexRuntimeV2::Model::StartConversationRequest startConvo;

    LexRuntimeV2::Model::StartConversationHandler convoHandler = LexRuntimeV2::Model::StartConversationHandler();

    convoHandler.SetTextResponseEventCallback(textEvent);
    convoHandler.SetIntentResultEventCallback(intentEvent);
    convoHandler.SetOnErrorCallback(errorEvent);
    convoHandler.SetHeartbeatEventCallback(heartbeatEvent);

    startConvo.WithBotId(BotId)
        .WithBotAliasId(BotAliasId)
        .WithLocaleId(Locale)
        .WithSessionId(ConvoSession)
        .WithEventStreamHandler(convoHandler)
        .WithConversationMode(Aws::LexRuntimeV2::Model::ConversationMode::TEXT);

    client.StartConversationAsync(startConvo, readyHandler, responseHandler);`

I get one call to "readyHandler" with the StartConversationRequestEventStream, but no calls to any of the other callbacks (responseHandler, heartbeatEvent, errorEvent, etc.) I'm trying to send various messages to the event stream with no luck--I would have thought I would at least get errors if they were not structured properly.

I'm currently running/testing on Windows. I've found a couple of references to full HTTP/2 streaming not being supported on Windows without using curl although I can't find any information about how to set this up.

It's entirely possible that I'm not making this call correctly, but the documentation is very thin for this API.

Expected behavior

Receive calls to the event callbacks.

Current behavior

Only the "ready" callback is called.

Steps to Reproduce

Code posted above.

Possible Solution

My guess is that the ready callback is simply called because the stream is ready for sending, but communication has not been established with the server. That said, there are no errors or any way to even find errors that I can find.

AWS CPP SDK version used

1.9.160

Compiler and Version used

VS 2019

Operating System and version

Windows 11

ryan-motive avatar Feb 23 '22 15:02 ryan-motive

Note that I can use that client to parse text directly with a call to "RecognizeText," so I know the client & bot are configured properly.

ryan-motive avatar Feb 23 '22 15:02 ryan-motive

@vudh1 thanks for taking this - on chat with support I am being told it's likely WinHttp vs. curl. Are there instructions for how to use curl with the SDK? I tried this to no avail:

` Aws::Client::ClientConfiguration config;

config.region = "us-west-2";
config.httpLibOverride = Aws::Http::TransferLibType::CURL_CLIENT;

LexRuntimeV2::LexRuntimeV2Client client(config);

`

Looking at the code it seems like I may need to re-build the SDK with ENABLE_CURL_CLIENT enabled?

ryan-motive avatar Feb 25 '22 17:02 ryan-motive

Hi @ryan-motive , Haven't had the time to look into this but regarding curl:

Looking at the code it seems like I may need to re-build the SDK with ENABLE_CURL_CLIENT enabled?

Yes, you would have to rebuild. Also keep in mind that you would need to not only set -DENABLE_CURL_CLIENT=ON, but to also set the -DCURL_LIBRARY=<curl_lib_path> -DCURL_INCLUDE_DIR=<curl_include_path> which for windows might be problematic. I recommend not using the default installation of curl on windows but to manually install it and explicitly point to that installation.

KaibaLopez avatar Feb 25 '22 21:02 KaibaLopez

Thanks @KaibaLopez - are there any docs for this? Haven't had to build an SDK manually for a while and honestly was hoping to never have to dig around build files ever again. :) I'd rather not trial-and-error my way through this if there's documentation somewhere.

ryan-motive avatar Feb 25 '22 23:02 ryan-motive

Depending on what you mean here... nothing specifically for Curl but if your question is how to build the SDK, then pretty much what is on the readme:

git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
cd aws-sdk-cpp
cmake -S . -B build -DBUILD_ONLY="lexv2-runtime" -DENABLE_CURL_CLIENT=ON -DCURL_LIBRARY=<curl_lib_path> -DCURL_INCLUDE_DIR=<curl_include_path> -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF
cmake --build build --config Debug
cmake --install build

Things to note here:

  • Add services to the build_only argument if necessary and have them separated by a ; . Like, you can add ec2 or dynamodb but if you aren't planning to use them then don't worry about it.
  • The install part will need admin permission because by default it will try to install in C:/Program Files(x86)/aws-sdk-all, you can change this by adding -DCMAKE_PREFIX_PATH=<install-location-that-doesn't-need-admin>

KaibaLopez avatar Feb 26 '22 00:02 KaibaLopez

Thanks so much - genuinely probably saved me a day of Googling :)

ryan-motive avatar Feb 26 '22 00:02 ryan-motive

I managed to get this up & running in a Docker Linux container. I'm now successfully receiving the heartbeat callbacks, but no others. I need to know the expected usage of this call. I'm using it as follows:

  • Call StartConversationAsync with a StartConversationHandler defining all of the callbacks
  • In the readyHandler callback I write ConfigurationEvent and TextInputEvent to the stream provided
  • I expect to receive a SetIntentResultEventCallback based on the text input, but I get nothing

If I provide the same text directly to the bot using client.RecognizeText I get a response with the expected values.

Really not sure where to turn--the documentation is very very poor for this API and there don't seem to be any examples of how to successfully use it. Is the StartConversationRequestEventStream that gets sent to readyHandler intended to be written to immediately? Is there another step or configuration required to call it?

If AWS could provide an example of this API working that would really help.

ryan-motive avatar Feb 27 '22 01:02 ryan-motive

We have been working on improving our docs. Please take a look and let me know if you have any specific questions about this sdk and how to use LexRuntime

jmklix avatar Mar 08 '23 18:03 jmklix

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Mar 11 '23 00:03 github-actions[bot]