DirectLine Speech service on Android emulators gets "Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED". No errors on Android physical devices.

Bruce Haley 95 Reputation points
2025-08-17T17:51:06.9433333+00:00

About 3 or 4 weeks ago, my MAUI chatbot client, when running on Android emulators, calling DirectLine speech service, started getting Connector_canceled WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED errors.

This bug reproduces using Microsoft's "Sample: Speech to text using the CognitiveServices Speech SDK for MAUI" at: https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/72f3cf794eff9d538fa2ed1e0e737f081f56276f/samples/csharp/maui/speech-to-text .

Repro steps:

  1. Clone the GitHub repo https://github.com/Azure-Samples/cognitive-services-speech-sdk
  2. In VS, open the solution at cognitive-services-speech-sdk\samples\csharp\maui\speech-to-text\speech-to-text.sln
  3. Edit the file cognitive-services-speech-sdk\samples\csharp\maui\speech-to-text\speech-to-text\MainPage.xaml.cs Replace "YourServiceRegion" and "YourSubscriptionKey" with the values for your speech service.
  4. Select any Android emulator as the target to run on. For example, Pixel 7 - API 36.
  5. Run the app.
  6. Tap the "Recognize speech" button, then say "Hello there" into the microphone.

Expected behavior: The app displays "RECOGNIZED: Text=Hello there."

Actual behavior: The app displays

"CANCELED: Reason=Error

CANCELED: ErrorCode=ConnectionFailure

CANCELED: ErrorDetails=Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED

wss://westus.api.cognitive.microsoft.com/stt/speech/universal/v2

X-ConnectionId: 8fefbdf27c5645ed9a10170e1e839a5a SessionId: 8fefbdf27c5645ed9a10170e1e839a5a

CANCELED: Did you update the subscription info?"

If you run the app on a physical Android device, it shows the expected behavior. The app gets no errors running on Android physical devices or on iPhone devices or iPhone simulators.

How can I get this sample app, and also my app, to run on Android emulators error-free?

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 36,716 Reputation points Volunteer Moderator
    2025-08-22T08:41:01.47+00:00

    Hello Bruce !

    Thank you for posting on Microsoft Learn.

    I think this isn’t your key/region or the Speech service. It’s an Android-emulator-side network/TLS problem that started showing up on recent AVD images.

    I found in this old thread, that several connection issues in older SDKs were fixed many people stuck on old versions saw identical failures until they upgraded.

    https://learn.microsoft.com/en-us/azure/ai-services/speech-service/releasenotes

    If you’re on a very new preview image (API 36/preview), try API 34 (Android 14) as a control. Google lists frequent emulator networking regressions; a fresh image + cold boot often clears them. https://developer.android.com/studio/run/emulator-troubleshooting

    You need to make sure that the emulator can handshake TLS to Speech Open Chrome inside the emulator and hit https://<your-region>.stt.speech.microsoft.com/ (or the URL your logs show). You should at least get a 404/landing page over HTTPS. If even that can’t load, you’re looking at emulator DNS/proxy/cert issues and not your app.

    https://learn.microsoft.com/en-us/answers/questions/1162970/ws-open-error-underlying-io-error-error-when-testi

    If you’re on a corporate network / SSL inspection Emulators don’t automatically trust your organization’s proxy CA. Do BOTH of these for debug runs:

    • Install the proxy/root CA into the emulator (Settings - Security - Encryption & credentials - Install a certificate - CA certificate).

    https://docs.mitmproxy.org/stable/howto/install-system-trusted-ca-android/

    https://docs.proxyman.com/debug-devices/android-device

    Tell your app to trust user CAs in debug builds with a Network Security Config:

    AndroidManifest.xml (debug only):

    <application android:networkSecurityConfig="@xml/network_security_config" ... />
    

    res/xml/network_security_config.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
      <debug-overrides>
        <trust-anchors>
          <certificates src="user"/>
        </trust-anchors>
      </debug-overrides>
    </network-security-config>
    

    If you must traverse an HTTP proxy, set it explicitly on the Speech SDK before creating the recognizer:

    speechConfig.SetProxy("proxy.mycorp.local", 8080);                  // or
    speechConfig.SetProxy("proxy.mycorp.local", 8080, "user", "pass");
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.