google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

Secure read failed

Open ricardo2197 opened this issue 10 years ago • 23 comments

Error every time I try to call Speech API (gRPC) after idle for a few minutes i get this error. Could you please tell me if there is a fix or a possible workaround?

Trace: { Error: Exception occurred in retry method that was not classified as transient
    at Object.callback (/home/ricardoungureanu/speech-to-text-api/node_modules/google-gax/lib/api_callable.js:147:19)
    at /home/ricardoungureanu/speech-to-text-api/node_modules/grpc/src/node/src/client.js:420:14
  cause: 
   { Error: {"created":"@1479751616.944318983","description":"Secure read failed","file":"../src/core/lib/security/transport/secure_endpoint.c","file_line":157,"grpc_status":14,"referenced_errors":[{"created":"@1479751616.944288215","description":"EOF","file":"../src/core/lib/iomgr/tcp_posix.c","file_line":235}]}
       at /home/ricardoungureanu/speech-to-text-api/node_modules/grpc/src/node/src/client.js:417:17 code: 14, metadata: Metadata { _internal_repr: {} } } }
    at Promise.all.then.all.then.all.then.catch (/home/ricardoungureanu/speech-to-text-api/src/app.js:186:32)
    at tryCatcher (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/promise.js:687:18)
    at Async._drainQueue (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/home/ricardoungureanu/speech-to-text-api/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)

ricardo2197 avatar Nov 21 '16 18:11 ricardo2197

Sorry about this. I believe this is a duplicate of #1796. @jmuk can you confirm?

stephenplusplus avatar Nov 21 '16 18:11 stephenplusplus

@stephenplusplus I think this is not. I mean, the error message is same but reporting a different thing.

@ricardo2197 The actual error message is the following part

{ Error: {"created":"@1479751616.944318983","description":"Secure read failed","file":"../src/core/lib/security/transport/secure_endpoint.c","file_line":157,"grpc_status":14,"referenced_errors":[{"created":"@1479751616.944288215","description":"EOF","file":"../src/core/lib/iomgr/tcp_posix.c","file_line":235}]}

This is an error of gRPC -- the underlying network/connection layer. I believe this happens due to network troubles between your machine and Google server, but I don't know any specific reason why this happens on your environment.

jmuk avatar Nov 21 '16 18:11 jmuk

Woops. Quick derail (sorry @ricardo2197!)-- I believe we thought about promoting the inner error to be the error that gax returns. I couldn't find an issue that backs up that belief though. Should I open a new issue on the gax repo?

Back to the Secure read failed error. It looks like we've run into this a few times:

  • https://github.com/grpc/grpc/issues/7804
  • https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1595#issuecomment-247165182

Even other languages are mentioned from the gRPC issue. Would you mind opening a new issue or comment on the one here with these details, as well as some more about your environment (OS, Node/npm versions, etc)?

stephenplusplus avatar Nov 21 '16 18:11 stephenplusplus

Sure, I will write a detailed report. Meanwhile, I may have found a workaround. Basically I am using the speech API to get transcripts of files with a delay of a few minutes between one and another file (after this period, when I send a new request the error is returned). The workaround I have found consists in requiring speech = require('@google-cloud/speech')(credentials) before each file, not once for all the files.

As I mentioned before, I will write a detailed report in the comment section in the link you specified. Thank you

ricardo2197 avatar Nov 21 '16 19:11 ricardo2197

Interesting, thanks for sharing. I'll look out for updates in case we need to do anything on our end.

stephenplusplus avatar Nov 29 '16 18:11 stephenplusplus

Hi @stephenplusplus - have you arrived upon a fix for this by any chance?

madhatter42 avatar Jan 05 '17 07:01 madhatter42

Hey @madhatter42, which issue are you having? We hit a couple things in this issue.

stephenplusplus avatar Jan 05 '17 21:01 stephenplusplus

The error message regarding the retry method that was not classified as transient is popping up when we're calling the speech to text service using the API.

On Fri, Jan 6, 2017 at 2:47 AM Stephen Sawchuk [email protected] wrote:

Hey @madhatter42 https://github.com/madhatter42, which issue are you having? We hit a couple things in this issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1811#issuecomment-270760169, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7zln1qdqToI2H9tNcyXPprWEcCQyHlks5rPV37gaJpZM4K4htC .

madhatter42 avatar Jan 06 '17 16:01 madhatter42

Can you log the error's cause property? That will tell us the exact error that is happening. (If it doesn't match the "secure read" one, please open a new issue)

stephenplusplus avatar Jan 06 '17 17:01 stephenplusplus

I'm still getting this error from Monitoring API, could someone here fix the @google-cloud/monitoring ?

{ Error: {"created":"@1485993840.827461818","description":"Secure read failed","file":"../src/core/lib/security/transport/secure_endpoint.c","file_line":157,"grpc_status":14,"referenced_errors":[{"created":"@1485993840.827426539","description":"EOF","file":"../src/core/lib/iomgr/tcp_posix.c","file_line":235}]}
    at /app/node_modules/@google-cloud/monitoring/node_modules/grpc/src/node/src/client.js:417:17
  code: 14,
  metadata: Metadata { _internal_repr: {} },
  note: 'Exception occurred in retry method that was not classified as transient' }

c0b avatar Feb 02 '17 00:02 c0b

https://www.npmjs.com/package/@google-cloud/monitoring 0.1.4 <= this one, depends on google-gax which still depends on [email protected] still generates above transient "Secure read failed"

➸ tail ./node_modules/@google-cloud/monitoring/node_modules/google-gax/node_modules/grpc/package.json
  },
  "scripts": {
    "coverage": "istanbul cover ./node_modules/.bin/_mocha src/node/test",
    "gen_docs": "jsdoc -c src/node/jsdoc_conf.json",
    "install": "node-pre-gyp install --fallback-to-build",
    "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore",
    "test": "mocha src/node/test && npm run-script lint"
  },
  "version": "1.0.1"
}

c0b avatar Feb 02 '17 00:02 c0b

@stephenplusplus I am seeing this issue as well using the language module. We see this error consistently after the API has been idle for a while. Hopefully the below will help.

Code

var languageClient = Language({
    projectId: appID,
    keyFilename: 'path/to/gcloudAuth.json'
});

var text = 'some text';
var opts = {verbose: true};
var doc = languageClient.document(text);
doc.detectEntities(opts, function(err, res) {
    if (err) {
        return cb(err);
    }
});

Error below.

{
    "message": {
        "created": '@1486520743.689057410',
        "description": 'Secure read failed',
        "file": '../src/core/lib/security/transport/secure_endpoint.c',
        "file_line": 157,
        "grpc_status": 14,
        "referenced_errors":
        [ {
            "created": '@1486520743.688867833',
            "description": 'EOF',
            "file": '../src/core/lib/iomgr/tcp_posix.c',
            "file_line": 235
        } ]
    }
    "code": 14,
    "metadata": {
        "_internal_repr": {}
    },
    "note": "Exception occurred in retry method that was not classified as transient"
}

kcoleman731 avatar Feb 08 '17 04:02 kcoleman731

I am trying to send the wav flies using a sample rate of 44100, but with a sample rate for 22100, its working Fine. Everytime i try i get this error.

{ Error: 502:Bad Gateway
    at /Users/rachit.r.agarwal/new_code_base/code-base/testFunctionalCaps/GoogleFunctionalCap/speechToText/node_modules/grpc/src/node/src/client.js:434:17
  code: 14,
  metadata: Metadata { _internal_repr: {} },
  note: 'Exception occurred in retry method that was not classified as transient' }

rachitagrwl avatar Feb 15 '17 09:02 rachitagrwl

According to this answer:

The gRPC error code in that error is 14, which means "Unavailable". This is a response from the server indicating that the service was unavailable when you made the request, and that you should wait a little and then try again.

We do automatic retries for read requests/readable streams (GET actions), but not for other writable API requests (POST actions). So, the solution for these cases might be to add in retry logic in your applications.

@rachitagrwl that might warrant a new issue to properly investigate. Could you open a new one and if at all possible, share audio files that would reproduce?

stephenplusplus avatar Feb 15 '17 14:02 stephenplusplus

Hi, Same here, using @google-cloud/language. Error occurs after calling the API after few idle minutes. The below was a sentiment analysis request with a simple text string coming in.

{ Error: {"created":"@1487324709.194979567","description":"Transport closed","file":"../src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1072}
     at /app/node_modules/grpc/src/node/src/client.js:434:17
   code: 13,
   metadata: Metadata { _internal_repr: {} },
   note: 'Exception occurred in retry method that was not classified as transient' }

Code used to call the API:

language.detectSentiment("text string", function(err, sentiment) {
// logic
});

Hope it helps!

petrnetusil avatar Feb 17 '17 09:02 petrnetusil

@stephenplusplus Thanks, Stephen, it works for me. Because google S2T, couldn't handle stereo audio. Therefore need to convert into Mono.

rachitagrwl avatar Feb 17 '17 09:02 rachitagrwl

Hello @stephenplusplus, according to your comment we need to manually retry the request if this happens? By any chance this can be handled automatically by node grpc client?

barroca avatar Mar 10 '17 01:03 barroca

@barroca what method are you calling that is returning the secure read error?

stephenplusplus avatar Mar 10 '17 01:03 stephenplusplus

sorry about not specifying the whole situation, my issue is not directly related to google-cloud-node, but it is a grpc issue that is very similar with it. If my connection is idle for a certain time i get the error 14 (unavailable) like this:

{ Error: {"created":"@1489105669.662840334","description":"Endpoint read failed","file":"../src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1851,"grpc_status":14,"occurred_during_write":0,"referenced_errors":[{"created":"@1489105669.662824070","description":"OS Error","errno":104,"fd":17,"file":"../src/core/lib/iomgr/tcp_posix.c","file_line":242,"os_error":"Connection reset by peer","syscall":"recvmsg","target_address":"ipv4:172.31.23.195:5001"}]}
    at /app/node_modules/grpc/src/node/src/client.js:434:17
  cause: 
   { Error: {"created":"@1489105669.662840334","description":"Endpoint read failed","file":"../src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1851,"grpc_status":14,"occurred_during_write":0,"referenced_errors":[{"created":"@1489105669.662824070","description":"OS Error","errno":104,"fd":17,"file":"../src/core/lib/iomgr/tcp_posix.c","file_line":242,"os_error":"Connection reset by peer","syscall":"recvmsg","target_address":"ipv4:172.31.23.195:5001"}]}
       at /app/node_modules/grpc/src/node/src/client.js:434:17 code: 14, metadata: Metadata { _internal_repr: {} } },
  isOperational: true,
  code: 14,
  metadata: Metadata { _internal_repr: {} } }

I'm using promise like this:

const client = grpc.$.transaction.raw_transaction();
const request = client.importAsync(req.body, metadata);
const [requestError, response] = await to(request);

barroca avatar Mar 10 '17 01:03 barroca

@barroca I'd like to know your runtime environment. @jskeet reported very similar error (grpc channel flakiness after idle).

jmuk avatar Mar 10 '17 03:03 jmuk