Azure-Samples / Cognitive-Speech-STT-iOS

iOS SDK for the Microsoft Speech-to-Text API, part of Cognitive Services
https://www.microsoft.com/cognitive-services/en-us/speech-api
Other
49 stars 21 forks source link

Getting Transport Error after updating from free trial account to standard account. Unable to get the Authorization token #48

Open rohitgadia opened 6 years ago

rohitgadia commented 6 years ago

Hi,

Recently one of our apps started using Azure's Speech to Text Service and initially, we had opted for a 7-day free trial account and used the keys obtained with this SDK integrated into the app. But as the trial keys were about to expire we upgrade our account to 'Standard' and got new keys. And after substituting the trial keys with the standard keys things started to fall apart and we got the 'Transport Error' everytime we invoked the service from our app. But when tested via Rest Client (PostMan) we realized that the issueToken call was failing as the endpoint was incorrect. The following the log trace for establishing the WebSocket connection for Short Phrase recognition.

2018-10-01 12:05:41.398352+0530 LexSwift[88412:5201410] Could not successfully update network info during initialization. 2018-10-01 12:05:41.402749+0530 LexSwift[88412:5201410] Could not successfully update network info during initialization. STS: https://api.cognitive.microsoft.com/sts/v1.0/issueToken Refreshing token /sts/v1.0/issueToken Initializing Audio Services Initializing Speech Services No application id provided to controller GetIdentityPropertyValue 3 Useragent Value iOS Assistant (iOS; 11.4;Mobile;ProcessName/AppName=com.fidelity.rapids.voice.ios/1.1.5.7;DeviceType=Near;SpeechClient=1.0.161216) Url: 'https://websockets.platform.bing.com/ws/speech/recognize' Locale: 'en-us' Application Id: '' Version: 4.0.150429 UserAuthorizationToken: ServerLoggingLevel: 1 Initiating websocket connection. m_connection=0x0 host=websockets.platform.bing.com port=443 originating error 0x80070057 Authorization token hr 80070057 '' originating error 0x8e200003 originating error 0x8e200003 Refreshing token /sts/v1.0/issueToken Successfully initialized client connection Create ImpressionId: 98b452611bb732c488142f351c772472 Create ImpressionId: 9aa6722da6ca71c940c11c3aabdd0a82 Reset Closing web socket channel Web socket channel closed (state = 0) originating error 0x8e200003 originating error 0x8e200003 Failed to 'CheckShutdown()', HR=80004005

Web socket handshake failed, hr=8E200003 web socket message delivery failed, hr=8E200003 No messages to retry, closing. Web socket channel already closed. originating error 0x8e200003 originating error 0x8e200003 Web socket channel already closed. Destroying WebSocketChannel Closing web socket channel Web socket channel closed (state = 0) WSRequest

Application Name: com.fidelity.rapids.voice.ios/1.1.5.7 2018-10-01 12:06:21.893015+0530 LexSwift[88412:5201410] Could not successfully update network info during initialization. 2018-10-01 12:06:21.896181+0530 LexSwift[88412:5201410] Could not successfully update network info during initialization. STS: https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken Refreshing token /sts/v1.0/issueToken Initializing Audio Services Initializing Speech Services No application id provided to controller GetIdentityPropertyValue 3 Useragent Value iOS Assistant (iOS; 11.4;Mobile;ProcessName/AppName=com.fidelity.rapids.voice.ios/1.1.5.7;DeviceType=Near;SpeechClient=1.0.161216) Url: 'https://websockets.platform.bing.com/ws/speech/recognize' Locale: 'en-us' Application Id: '' Version: 4.0.150429 UserAuthorizationToken: ServerLoggingLevel: 1 Initiating websocket connection. m_connection=0x0 host=websockets.platform.bing.com port=443 originating error 0x80070057 Authorization token hr 80070057 '' originating error 0x8e200003 originating error 0x8e200003 originating error 0x8e200003 originating error 0x8e200003 Refreshing token /sts/v1.0/issueToken WebSocket closed unexpectedly, status: 0 Closing web socket channel Web socket channel closed (state = 0) Web socket handshake failed, hr=8E200003 Successfully initialized client connection web socket message delivery failed, hr=8E200003 No messages to retry, closing. Web socket channel already closed. Create ImpressionId: 4df6d55e122fac1cd0ffd78ac7d3c58e Create ImpressionId: 4cc7418302b751881342545ca1f8a743 Reset 2018-10-01 12:06:42.711082+0530 LexSwift[88412:5201410] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/a594258/Library/Developer/CoreSimulator/Devices/36DBBB01-33BE-4219-8127-4FB824034076/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2018-10-01 12:06:42.718231+0530 LexSwift[88412:5201410] [MC] Reading from private effective user settings. originating error 0x8e200003 originating error 0x8e200003

We read through the documentation and the default endpoint to obtain the token based on the subscription key was wrong so we updated the endpoint using one of the setter methods on a variable.

https://docs.microsoft.com/en-us/azure/cognitive-services/custom-speech-service/customspeech-how-to-topics/cognitive-services-custom-speech-use-endpoint#send-requests-by-using-the-speech-protocol

self.micClient = SpeechRecognitionServiceFactory.createMicrophoneClient(SpeechRecognitionMode.shortPhrase, withLanguage: "en-us", withKey: azurePrimaryKey, with: self) self.micClient.authenticationUri = "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken"

We tested this in the Rest Client (PostMan) using our API keys and we were able to get the authorization token on hitting the above-mentioned endpoint. But updating that in our code hasn't done much good. Can you please help us or guide us on how this can be fixed ?