watson-developer-cloud/speech-to-text-nodejs

With IAM authentication, I got "WebSocket connection error"

HiroOgata opened this issue · 12 comments

I got "WebSocket connection error" with IAM authentication (using resource group STT instance and "SPEECH_TO_TEXT_IAM_APIKEY=" in .env file).
Just I switch the STT instance to CF instance (with username and password), it worked fine (using "SPEECH_TO_TEXT_USERNAME=", "SPEECH_TO_TEXT_PASSWORD=" in .env file)

@HiroyoshiOgata The problem is in the speech-javascript-sdk and was fixed in this PR: https://github.com/watson-developer-cloud/speech-javascript-sdk/pull/69/files

We need to update this sample to use the newest version of the SDK and send the access_token rather than token

Fixed in #206

Hello, I'm having a similar issue. However I'm not using IAM authentication and I'm also getting the WebSocket error. Is Fixed #206 work for non-IAM authentication ?

You need to migrate your service to IAM.

Hi, I'm using IAM with the latest version of the SDK (3.16.1). I instantiate SpeechToTextV1 with my APIKey. It works for a while and then I get the WebSocket error. I have to assume it is when the token expires and the SDK doesn't automatically refresh it.

If the connection was established the token isn't needed anymore. I think this is a problem where the server had a problem and closed the connection.

For how long was the connection open?

Probably an hour or more, but I'm not sure how long the connection is open. I'm just using the recognizeUsingWebSocket operation on the SpeechToTextV1 class. I process many files with the same instance of the class, but at some point, it starts failing. This problem has been happening for days now, so I doubt it is a server/service issue. I might need to move the initialization of the SpeechToTextV1 class down into my function that calls recognizeUsingWebSocket to re-establish the connection each time I process an audio file.

I keep getting the websocket error, but it looks like the implementation of this demo app was built using a previous version of the SDK. Any chance you can tell me what should I change to make it work correctly?

One of the things I have been reading is that IBM Documentation refers is that I should update from using RecognizeMicrophone to RecognizeWebSocket. This app is just not running locally, I keep getting the Websocket error...

This app is using the old version of the SDK but it should work. Check that you are using the credentials as you are supposed to do. I'm 100% sure this is a problem in your code where you are not setting the URL or the apikey correctly

Hi, I'm getting the same websocket error - it allows me to play the recording for less than a second and then the error occurs. I downloaded the gitrepo tonight and it has the changes in you've described above.