aws-sdk-cpp
aws-sdk-cpp copied to clipboard
Aws streaming transcribe "Encountered network error when sending http request" - Windows
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [ x] I've gone though Developer Guide and API reference
- [ x] I've searched for previous similar issues and didn't find any solution
Describe the bug I using aws transcribe streaming in windows platform, three weeks ago it still working, but from yesterday it no longer working and I did not modified my code as well, it just suddenly not working. I assume there are some windows update probably it affect the winHttp? The log message show that Http response code -1 and the message is "Error message: Encountered network error when sending http request". I using the sample code from aws sample
SDK version number 1.9.132
Platform/OS/Hardware/Device Windows 10 Pro 64-bit
To Reproduce (observed behavior)
- Copy the code from https://aws.amazon.com/blogs/developer/real-time-streaming-transcription-with-the-aws-c-sdk/
- Install the required packages.
- Make sure you run the code in Windows 10 platform.
Expected behavior A clear and concise description of what you expected to happen.
Logs/output
[DEBUG] 2021-10-29 05:16:35.724 AWSAuthEventStreamV4Signer [22388] Final computed signing hash: 447eabe70ef4d2a16aca6f0bc85ab7b7e61fd9d7e09fad65a171e54fbce0b217 [INFO] 2021-10-29 05:16:35.724 AWSAuthEventStreamV4Signer [22388] Event chunk final signature - 447eabe70ef4d2a16aca6f0bc85ab7b7e61fd9d7e09fad65a171e54fbce0b217 [WARN] 2021-10-29 05:16:35.724 WinInetSyncHttpClient [34112] Send request failed: The connection with the server was reset
[DEBUG] 2021-10-29 05:16:35.724 WinInetSyncHttpClient [34112] Closing http request handle 0000000000CC0010 [DEBUG] 2021-10-29 05:16:35.724 WinInetSyncHttpClient [34112] Releasing connection handle 0000000000CC000C [DEBUG] 2021-10-29 05:16:35.724 WinInetConnectionPoolMgr [34112] Releasing connection to endpoint transcribestreaming.us-east-1.amazonaws.com:443 [DEBUG] 2021-10-29 05:16:35.724 AWSClient [34112] Request returned error. Attempting to generate appropriate error codes from response [ERROR] 2021-10-29 05:16:35.725 AWSClient [34112] HTTP response code: -1 Resolved remote host IP address: Request ID: Exception name: Error message: Encountered network error when sending http request 0 response headers: [WARN] 2021-10-29 05:16:35.725 AWSClient [34112] If the signature check failed. This could be because of a time skew. Attempting to adjust the signer. [DEBUG] 2021-10-29 05:16:35.725 AWSClient [34112] Date header was not found in the response, can't attempt to detect clock skew [WARN] 2021-10-29 05:16:35.725 AWSClient [34112] Request failed, now waiting 0 ms before attempting again. [DEBUG] 2021-10-29 05:16:35.725 AWSAuthEventStreamV4Signer [34112] Canonical Header String: amz-sdk-invocation-id:A9D4FB0D-3359-4B92-A407-069D6DFF8EE6 amz-sdk-request:attempt=2; max=11 content-type:application/vnd.amazon.eventstream host:transcribestreaming.us-east-1.amazonaws.com x-amz-api-version:2017-10-26 x-amz-content-sha256:STREAMING-AWS4-HMAC-SHA256-EVENTS x-amz-date:20211029T051635Z x-amzn-transcribe-language-code:en-US x-amzn-transcribe-media-encoding:pcm x-amzn-transcribe-sample-rate:16000
............
[DEBUG] 2021-10-29 05:16:36.004 AWSAuthEventStreamV4Signer [22388] Final computed signing hash: da844917724a8b705b6cca206dfae1779bdee9d908da0820143d65c8da4c6208 [INFO] 2021-10-29 05:16:36.004 AWSAuthEventStreamV4Signer [22388] Event chunk final signature - da844917724a8b705b6cca206dfae1779bdee9d908da0820143d65c8da4c6208 [DEBUG] 2021-10-29 05:16:36.012 WinInetSyncHttpClient [34112] Received response code 200 [DEBUG] 2021-10-29 05:16:36.012 WinInetSyncHttpClient [34112] Received content type application/vnd.amazon.eventstream [DEBUG] 2021-10-29 05:16:36.012 WinInetSyncHttpClient [34112] Received headers: [DEBUG] 2021-10-29 05:16:36.012 WinInetSyncHttpClient [34112] HTTP/1.1 200
x-amzn-requestid: 5d6eb74e-5ce2-4270-9cb5-d1189a8b2f76
x-amzn-transcribe-enable-channel-identification: false
x-amzn-transcribe-language-code: en-US
x-amzn-transcribe-sample-rate: 16000
x-amzn-request-id: 5d6eb74e-5ce2-4270-9cb5-d1189a8b2f76
x-amzn-transcribe-enable-partial-results-stabilization: false
x-amzn-transcribe-session-id: 26c0b7b0-275a-4d2a-a352-e233b70604b0
x-amzn-transcribe-show-speaker-label: false
x-amzn-transcribe-media-encoding: pcm
date: Fri, 29 Oct 2021 05:16:31 GMT
content-type: application/vnd.amazon.eventstream
[TRACE] 2021-10-29 05:16:36.013 Aws::Utils::Event::EventStreamDecoder [34112] Message received, the expected length of the message is: 188 bytes, and the expected length of the header is: 97 bytes [WARN] 2021-10-29 05:16:36.013 StartStreamTranscriptionHandler [34112] Encountered AWSError 'BadRequestException': A complete signal was sent without the preceding empty frame. [TRACE] 2021-10-29 05:16:36.013 StartStreamTranscriptionHandler [34112] TranscribeStreamingService Errors received, HTTP response code: -1 Resolved remote host IP address: Request ID: Exception name: BadRequestException Error message: A complete signal was sent without the preceding empty frame. 0 response headers: [DEBUG] 2021-10-29 05:16:36.013 WinInetSyncHttpClient [34112] Closing http request handle 0000000000CC0010 [DEBUG] 2021-10-29 05:16:36.013 WinInetSyncHttpClient [34112] Releasing connection handle 0000000000CC000C [DEBUG] 2021-10-29 05:16:36.013 WinInetConnectionPoolMgr [34112] Releasing connection to endpoint transcribestreaming.us-east-1.amazonaws.com:443 [DEBUG] 2021-10-29 05:16:36.013 AWSClient [34112] Request returned successful response. [TRACE] 2021-10-29 05:16:36.013 AWSClient [34112] Request successful returning.
To enable logging, set the following system properties:
REMEMBER TO SANITIZE YOUR PERSONAL INFO
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options)
Additional context I got modified a bit the code (main.cpp from the sample) when getting the credential if you compare to the aws sample
#include <aws/core/Aws.h>
#include <aws/core/utils/threading/Semaphore.h>
#include <aws/transcribestreaming/TranscribeStreamingServiceClient.h>
#include <aws/transcribestreaming/model/StartStreamTranscriptionHandler.h>
#include <aws/transcribestreaming/model/StartStreamTranscriptionRequest.h>
#include <aws/core/auth/AWSCredentials.h>
#include <cstdio>
using namespace Aws;
using namespace Aws::TranscribeStreamingService;
using namespace Aws::TranscribeStreamingService::Model;
int SampleRate = 16000; // 16 Khz
int CaptureAudio(AudioStream& targetStream);
Aws::Auth::AWSCredentials GetCredential(std::string access_id, std::string access_key)
{
return Aws::Auth::AWSCredentials(access_id, access_key);
}
int main()
{
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options);
{
Aws::Client::ClientConfiguration config;
config.region = Aws::Region::US_EAST_1;
#ifdef _WIN32
config.httpLibOverride = Aws::Http::TransferLibType::WIN_INET_CLIENT;
#endif
TranscribeStreamingServiceClient client(GetCredential("REPLACE TO YOUR ID", "REPLACE TO YOUR KEY"), config);
StartStreamTranscriptionHandler handler;
handler.SetTranscriptEventCallback([](const TranscriptEvent& ev) {
for (auto&& r : ev.GetTranscript().GetResults()) {
if (r.GetIsPartial()) {
printf("[partial] ");
}
else {
printf("[Final] ");
}
for (auto&& alt : r.GetAlternatives()) {
printf("%s\n", alt.GetTranscript().c_str());
}
}
});
StartStreamTranscriptionRequest request;
request.SetMediaSampleRateHertz(SampleRate);
request.SetLanguageCode(LanguageCode::en_US);
request.SetMediaEncoding(MediaEncoding::pcm);
request.SetEventStreamHandler(handler);
auto OnStreamReady = [](AudioStream& stream) {
CaptureAudio(stream);
stream.flush();
stream.Close();
};
Aws::Utils::Threading::Semaphore signaling(0 /*initialCount*/, 1 /*maxCount*/);
auto OnResponseCallback = [&signaling](const TranscribeStreamingServiceClient*,
const Model::StartStreamTranscriptionRequest&,
const Model::StartStreamTranscriptionOutcome& out,
const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) {
auto error = out.GetError().GetMessage();
signaling.Release();
};
client.StartStreamTranscriptionAsync(request, OnStreamReady, OnResponseCallback, nullptr /*context*/);
client.EnableRequestProcessing();
signaling.WaitOne(); // prevent the application from exiting until we're done
}
Aws::ShutdownAPI(options);
return 0;
}
Exactly the same code in macos works fine.
Were you able to figure this out? I am encountering the same issue.
Were you able to figure this out? I am encountering the same issue.
I have no idea now, but I assuming is WinInet problem, because the same code last time was working fine, but suddenly it broken without changing any coding or upgrading aws-sdk. I did try other languages of aws transcribe streaming (java and python), it all works fine on windows.
I think this can be a Windows firewall issue and it's blocking the specific app. Nothing to do with AWS-SDK, actually.
On Sun, Dec 5, 2021 at 8:05 PM ee sheng yuen @.***> wrote:
Were you able to figure this out? I am encountering the same issue.
I have no idea now, but I assuming is WinInet problem, because the same code last time was working fine, but suddenly it broken without changing any coding or upgrading aws-sdk. I do try other languages of aws transcribe streaming (java and python), it all works fine on windows.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aws/aws-sdk-cpp/issues/1805#issuecomment-986348515, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYDXHFYTX7GCJVHYY55FYTUPQD3ZANCNFSM5G6PUA5Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
this is duplicate issue with the one I posted. And it was confirmed that it is a bug in Windows. Simply it stopped working. It is not firewall issue
aws sdk cpp sample for transcribe stopped working #1806
hmm it took some time but I found a solution. Just pass the config with right region to s3 client constructor, then it will be ok. My bucket address was handled as "us" region.. (in the log). I hope this can be a clue to sdk dev team.
Please check out the new transcribe streaming example. Please let me know if you are still getting a network error, but if you encounter any other problems please open a new issue.
@alanee1996 hey mate, were you able to solve it somehow?