Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.82k stars 1.83k forks source link

Java Project Use SDK occur Errors:"Failed to get HTTP platform singleton instance" and "Failed to initialize platform (azure-c-shared). Error: 2176" #2483

Closed leceshide closed 2 months ago

leceshide commented 2 months ago

OS and JDK environment version:

1、 OpenSSL Version

OpenSSL 3.2.0 23 Nov 2023 (Library: OpenSSL 3.2.0 23 Nov 2023)

2、OS version cat /etc/os-release

NAME="CentOS Stream" VERSION="9" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" ANSI_COLOR="0;31" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:centos:centos:9" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://issues.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

3、JDK version

java --version java 21.0.1 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

4、client-sdk version

`

com.microsoft.cognitiveservices.speech
            <artifactId>client-sdk</artifactId>
            <version>1.37.0</version>
        </dependency> 

`

BTW:
First time I used 1.38.0 version. It occurred these error messages: ` CANCELED: ErrorDetails=Failed to get HTTP platform singleton instance. Error: 27 SessionId: c8815eb82e814609a60d0aa122acd119

Today I use 1.37.0 version. It not work yet. Occurred new errors: java.lang.RuntimeException: Runtime error: Failed to initialize platform (azure-c-shared). Error: 2176 `

I also read this page to update OS Library Dependencies. But also not work : https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/how-to-configure-rhel-centos-7

(I updated all of library dependencies, but no use gcc-7.5.0. Because my OS gcc version is : 11.4.1 )

[ gcc --version gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ]

I agree to provide one all-in-one SDK solution is convenient. But we can provide a simple implementation for specific scenarios.

In my case, I just need to implement text-to-speech and speech recognition through remote calls, without use local hardware.

leceshide commented 2 months ago

java.lang.RuntimeException: Runtime error: Failed to initialize platform (azure-c-shared). Error: 2176 at com.microsoft.cognitiveservices.speech.util.Contracts.throwIfFail(Unknown Source) at com.microsoft.cognitiveservices.speech.SpeechSynthesizer.(Unknown Source)

leceshide commented 2 months ago

I read this page: https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/how-to-use-logging , and I added log for Azure Service. Luckly I saw the error message is OS lost libssl. So I upgrade it.

Centos Stream9 install libssl:

` sudo dnf install -y compat-openssl11

` After did this, I saw this error messages:

` [169145]: 499817ms SPX_TRACE_INFO: usp_connection.cpp:933 TS:289, TransportError: connection:0xf043a020, code=5, string=Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED wss://en-US.stt.speech.microsoft.com/speech/universal/v2 X-ConnectionId: 91f7e09837a14586a32bf778d553d2e8 [169145]: 499817ms SPX_TRACE_ERROR: usp_reco_engine_adapter.cpp:2009 Response: On Error: Code:5, Message: Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED wss://en-US.stt.speech.microsoft.com/speech/universal/v2 X-ConnectionId: 91f7e09837a14586a32bf778d553d2e8. [169145]: 499817ms SPX_DBG_TRACE_VERBOSE: usp_reco_engine_adapter.cpp:3033 TryChangeState; audioState/uspState: 2/1000 => 2/-1 USP-ERRORERROR [169145]: 499817ms SPX_TRACE_ERROR: usp_reco_engine_adapter.cpp:2023 OnError: site->Error() ... error='Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED wss://en-US.stt.speech.microsoft.com/speech/universal/v2 X-ConnectionId: 91f7e09837a14586a32bf778d553d2e8'

`

pankopon commented 2 months ago

Centos Stream9

Sorry, but regardless of gcc or openssl versions this is an unsupported environment. Ref. https://learn.microsoft.com/azure/ai-services/speech-service/quickstarts/setup-platform?tabs=linux&pivots=programming-language-java#platform-requirements

However, if not already tried, you could check whether setting SSL_CERT_FILE helps as instructed in https://learn.microsoft.com/azure/ai-services/speech-service/how-to-configure-openssl-linux?pivots=programming-language-java

leceshide commented 2 months ago

Thank you very much! When I upgraded libssl , I fix this problem! Now sdk is work well !

Centos Stream9

Sorry, but regardless of gcc or openssl versions this is an unsupported environment. Ref. https://learn.microsoft.com/azure/ai-services/speech-service/quickstarts/setup-platform?tabs=linux&pivots=programming-language-java#platform-requirements

However, if not already tried, you could check whether setting SSL_CERT_FILE helps as instructed in https://learn.microsoft.com/azure/ai-services/speech-service/how-to-configure-openssl-linux?pivots=programming-language-java

xmkevin commented 2 months ago

Thank you very much! When I upgraded libssl , I fix this problem! Now sdk is work well !

Centos Stream9

Sorry, but regardless of gcc or openssl versions this is an unsupported environment. Ref. https://learn.microsoft.com/azure/ai-services/speech-service/quickstarts/setup-platform?tabs=linux&pivots=programming-language-java#platform-requirements However, if not already tried, you could check whether setting SSL_CERT_FILE helps as instructed in https://learn.microsoft.com/azure/ai-services/speech-service/how-to-configure-openssl-linux?pivots=programming-language-java

what libssl did you upgrade ? I use open ssl 3.2.2, it does not work either.

pankopon commented 3 weeks ago

@xmkevin Use the current latest Speech SDK 1.40.0 release. It removes the OpenSSL version limit (previously 3.0.x maximum) so any 3.x may work (but no guarantee).