question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to contact server. StatusCode: 1006, undefined Reason

See original GitHub issue

I just copied and pasted the node js code and replace the filename, key, and region but it throws the following error:

E:\Upwork\stt\stt-new\controllers>node microsoft.js Now recognizing from: m1561477818826.wav SpeechRecognitionResult { privResultId: ‘1530E7597EE7496E91747B86931F79F9’, privReason: 1, privText: undefined, privDuration: undefined, privOffset: undefined, privErrorDetails: 'Unable to contact server. StatusCode: 1006, undefined Reason: ', privJson: undefined, privProperties: PropertyCollection { privKeys: [ ‘CancellationErrorCode’ ], privValues: [ ‘ConnectionFailure’ ] } } Trace: err - Runtime error: Unable to contact server. StatusCode: 1006, undefined Reason: at E:\Upwork\stt\stt-new\controllers\microsoft.js:56:13 at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\sdk\SpeechRecognizer.js:157:21 at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\sdk\Recognizer.js:129:17 at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:351:21) at Sink.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:318:23) at Deferred.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:281:28) at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:193:46 at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:351:21) at Sink.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:318:23) at Deferred.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:281:28) E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:354 throw new Error(“‘Unhandled callback error: " + e + ". InnerError: " + error + "’”); ^

Error: ‘Unhandled callback error: Error: ‘Cannot reject a completed promise’. InnerError: ‘Unhandled callback error: Error: ‘Cannot reject a completed promise’’’ at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:354:27) at Sink.executeSuccessCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:345:23) at Sink.resolve (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:306:23) at Deferred.resolve (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:277:28) at WebSocket._this.privWebsocketClient.onclose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common.browser\WebsocketMessageAdapter.js:107:59) at WebSocket.onClose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\event-target.js:124:16) at WebSocket.emit (events.js:182:13) at WebSocket.emitClose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\websocket.js:182:12) at ClientRequest.req.on (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\websocket.js:569:15) at ClientRequest.emit (events.js:182:13)

Here is my code


var sdk = require("microsoft-cognitiveservices-speech-sdk");
var fs = require("fs");

// replace with your own subscription key,
// service region (e.g., "westus"), and
// the name of the file you want to run
// through the speech recognizer.
var subscriptionKey = "*****************";
var serviceRegion = "westus"; // e.g., "westus"
var filename = "m1561477818826.wav"; // 16000 Hz, Mono

// create the push stream we need for the speech sdk.
var pushStream = sdk.AudioInputStream.createPushStream();

// open the file and push it to the push stream.
fs.createReadStream(filename).on('data', function(arrayBuffer) {
  pushStream.write(arrayBuffer.buffer);
}).on('end', function() {
  pushStream.close();
});

// we are done with the setup
console.log("Now recognizing from: " + filename);

// now create the audio-config pointing to our stream and
// the speech config specifying the language.
var audioConfig = sdk.AudioConfig.fromStreamInput(pushStream);
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);

// setting the recognition language to English.
speechConfig.speechRecognitionLanguage = "en-US";

// create the speech recognizer.
var recognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);

// start the recognizer and wait for a result.
recognizer.recognizeOnceAsync(
  function (result) {
    console.log(result);

    recognizer.close();
    recognizer = undefined;
  },
  function (err) {
    console.trace("err - " + err);

    recognizer.close();
    recognizer = undefined;
  });

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
wolfma61commented, Jul 2, 2019

@therowf - please edit the message remove your subscription key!

3reactions
beelzabubcommented, Oct 1, 2019

Has anybody come to a resolution on this? I am having the same issue. My subscription key and region are correct but still get the “Unable to contact server” message.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Speech service return error 1006 - Microsoft Q&A
Trying to use Speech service (TextToSpeech) Getting error: Unable to contact server. StatusCode: 1006, undefined Reason: getaddrinfo ...
Read more >
[SOLVED] code server WebSocket close with status code 1006
The main reason is that the connection was closed abnormally (locally) by the browser implementation. It means that your browser cannot reach ...
Read more >
javascript - Chrome JS websocket Unable to contact server ...
StatusCode : 1006, undefined Reason: undefined. I cannot find more specific information in console log. The problem only happens with wss (https) ...
Read more >
The workbench failed to connect to the server (Error
Hello I am trying to connect a remote machine to the WEB IDE, ... to connect to the server (Error: WebSocket close with...
Read more >
WebSocket Status Codes Cheat Sheet
1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found