noopkat / ms-bing-speech-service

NodeJS service wrapper for Microsoft Speech API and Custom Speech Service
MIT License
82 stars 17 forks source link

Error 'connection failed' when upgrading from v1.3.3 to v2.0.1 #18

Closed e-compton closed 6 years ago

e-compton commented 6 years ago

Hi,

I'm experiencing an odd error when upgrading this package to the newer v2.0.1.

connection.start() throws a socket error with reason connection failed, even though this._options has not changed and works in v1.3.3 (using language, issueTokenUrl, serviceUrl and subscriptionKey).

Code:

acquire(cb) {
    debug('Giving Connection');
    let connection = new speechClient(this._options);

    connection.start().then(() => process.nextTick(() => {
      cb(null, connection);
    })).catch(err => process.nextTick(() => cb(err)));
  }

Full error:

 speechService socket error: _Event {
  type: 'error',
  isTrusted: false,
  _yaeti: true,
  target: 
   W3CWebSocket {
     _listeners: {},
     addEventListener: [Function: _addEventListener],
     removeEventListener: [Function: _removeEventListener],
     dispatchEvent: [Function: _dispatchEvent],
     _url: '<removed for security reasons>',
     _readyState: 3,
     _protocol: undefined,
     _extensions: '',
     _bufferedAmount: 0,
     _binaryType: 'arraybuffer',
     _connection: undefined,
     _client: 
      WebSocketClient {
        domain: null,
        _events: {},
        _eventsCount: 0,
        _maxListeners: undefined,
        config: [Object],
        _req: null,
        protocols: [],
        origin: undefined,
        url: [Object],
        secure: true,
        base64nonce: '3JE7wIKvwWUGZhRMeVOpbQ==' },
     onmessage: [Function: bound onMessage],
     onerror: [Function],
     onclose: [Function],
     onopen: [Function] },
  cancelable: true,
  stopImmediatePropagation: [Function] } +51s
  speechService socket close: _Event {
  type: 'close',
  isTrusted: false,
  _yaeti: true,
  code: 1006,
  reason: 'connection failed',
  wasClean: false,
  target: 
   W3CWebSocket {
     _listeners: {},
     addEventListener: [Function: _addEventListener],
     removeEventListener: [Function: _removeEventListener],
     dispatchEvent: [Function: _dispatchEvent],
     _url: '<removed for security reasons>',
     _readyState: 3,
     _protocol: undefined,
     _extensions: '',
     _bufferedAmount: 0,
     _binaryType: 'arraybuffer',
     _connection: undefined,
     _client: 
      WebSocketClient {
        domain: null,
        _events: {},
        _eventsCount: 0,
        _maxListeners: undefined,
        config: [Object],
        _req: null,
        protocols: [],
        origin: undefined,
        url: [Object],
        secure: true,
        base64nonce: '3JE7wIKvwWUGZhRMeVOpbQ==' },
     onmessage: [Function: bound onMessage],
     onerror: [Function],
     onclose: [Function],
     onopen: [Function] },
  cancelable: true,
  stopImmediatePropagation: [Function] }
noopkat commented 6 years ago

Hi @e-compton, thanks for reporting this issue. Sorry that you're having troubles upgrading this package in your codebase.

Could you please try running your code again, with DEBUG=speechService set as an environment variable? eg. DEBUG=speechService node myfile.js

Feel free to sanitize anything you need to in the output, before pasting it in here.

Thanks in advance for the help! bitmoji

noopkat commented 6 years ago

update - Looks like you were using a custom speech service endpoint? I've issued a patch that I've manually tested on my end. Could you please retest your migration code with v2.0.2 which has the patch in it? Thanks!

e-compton commented 6 years ago

Yes, I am using a custom speech endpoint.

The new patch v2.0.2 works perfectly thank you :)

noopkat commented 6 years ago

great to hear! Thanks for your help again and I'm glad we could get you unstuck. Closing this issue.

bitmoji