You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Package name and version smarthome-relay@1.3.8 /relay
├─┬ google-assistant@0.5.2
│ └── grpc@1.17.0 deduped
└── grpc@1.17.0
Additional context
it happens randomly but it start doing that since ~1 month back
Reacted by Kyle McCarthy, Marie Hoeger, Sergio Regueira, Jeff Tian, sensuikan1973, Ed Jeon (전무익), WaldoJeffers, Trym Nilsen, kaskazurek, RyanMcDonagh and 9 more
I am having this same issue on Google App Engine standard, node 10.
I am using @google-cloud/logging-winston which depends on @google-cloud/logging and that depends on @google-cloud/common-grpc which uses this package. So I can't say what is causing this issue.
Is this a problem with this package or how other packages implement it?
Error: 14 UNAVAILABLE: TCP Read failed at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:87:15) at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1188:28) at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:564:42) at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:614:8) at callback (/srv/node_modules/grpc/src/client_interceptors.js:841:24)
Reacted by WaldoJeffers, Trym Nilsen and DingRui Yang
The status responses described here are expected behavior of gRPC itself. Generally, we expect that some responses, including UNAVAILABLE, should be retried. In these cases the library that uses gRPC should perform the retry logic, as described in that linked issue.
@murgatroid99 the problem is gRPC library does not reconnect after that error, so applications stop sending logs to Stackdriver. When this happens, we have to replace the affected instance with a new one.
First, to make sure that we're on the same page, the way gRPC reconnection is supposed to work is that if a connection fails, then the next time the user starts a call the library starts trying to reestablish the connection. A user that retries failed UNAVAILABLE requests should trigger that reconnection.
So, are you saying that the Stackdriver library is retrying the failed request after the connection drops, and when it does so the gRPC library never reestablishes the connection? If so, that is a major bug that we are otherwise unaware of, so please file a full bug report with reproduction steps.
To add some details here. Client libraries use gRPC via the gax layer, and that gax layer can send retries if the library is configured so. By 'configured so' I mean the JSON configuration file that is passed to client library constructor. If this file mentions that the given method is idempotent - i.e. it is safe to retry it - gax layer will do the retries. If it's non-idempotent, just like all POST methods, it won't be retried automatically and it should be taken care of by the caller.
In logging library, the configuration file is here. @crwilcox made a change 2 weeks ago to treat all the logging method as idempotent, which means that you might get a duplicated log line in case of a retry, but you should not get fails: googleapis/nodejs-logging#366 It does not fix the TCP error that makes gRPC fail, but at least it should make gax retry the failed call (we are now talking only about logging libraries).
Let us make a new release of the logging library, it should fix most of the problems related to logging libraries. For other libraries, let's go one by one and see what's going on, but in general, the caller code should be ready to get UNAVAILABLE (it's a network, so any call can technically fail), and retrying UNAVAILABLE for non-idempotent methods is something your code should take care of.
The same day you asked me for more information, I enabled gRPC debugging setting some environment variables (GRPC_TRACE=tcp GRPC_VERBOSITY=DEBUG) and I monitored the logs during several days.
I could check, as you mentioned, that nodejs-logging tries to reconnect automatically when something fails. This is an example where it reconnects successfully (and logs continue being persisted):
I think the change done by @crwilcox will reduce the probability of lost logs due to request errors but the error that I have just detailed will continue happening.
For operations deemed non-idempotent, such as the case with things like WriteLogEntries, the RPC call that underlies many logging calls, it isn't necessarily safe for the client to retry. A decision was made in this case that duplicated logs are preferable to not logging. There unfortunately will exist other non-idempotent RPCs that will be more complicated.
@sergioregueira When you say that the logs ceased, do you mean that in each case, that is the last log line output from that process, and that the other logs come from different processes? If so, what is the behavior of those processes after they stop outputting logs?
Also, I don't know exactly what behavior of the gRPC library we are seeing here, but the expected behavior is not that the library always reconnects; it generally only reconnects if there is an existing pending request. Do any of the logs you have show that it is failing to reconnect while there is a pending request. If not, you may need to get more trace information to see that information. The api tracer should help, so you can modify the environment variables to have GRPC_TRACE=api,tcp. The full list of available tracers is in this document.
@murgatroid99 I mean the application continues working properly but Stackdriver does not process more logs of the affected instance (including gRPC traces). Logs generated automatically (ie. appengine.googleapis.com/request_log) are not interrupted.
When that error happens I have to delete the affected instance because the logs generated by that instance after the error are not registered.
The logs I attached in my previous post is all I could obtain after the errors. I will update right now that environment variable to get more information. If you have additional suggestions to debug the problem just let me know.
I just want to make sure I am understanding this correctly. You are using the Stackdriver logger to save the gRPC logs generated from that same Stackdriver logger, which you are using to debug why the logger is failing?
On the one hand, our application logs are sent to Stackdriver via nodejs-logging (that uses internally gRPC) in a structured way (using LogEntry.jsonPayload object).
On the other hand, gRPC logs are printed by the library itself to stdout/stderr (we did not have to code anything) and collected automatically by Stackdriver (as simple LogEntry.textPayload string).
In conclusion, we use logs that are NOT sent via gRPC to debug gRPC protocol.
Actually, it would probably help the most to run with GRPC_TRACE=all. That will tell us with the greatest granularity possible the very last things the gRPC library does before we stop getting logs.
@stuckj I'm seeing the same pattern on our AWS Lambda functions using the firestore client (latest version).
I was able to reproduce almost 100% of the cases in our dev environment.
I think this is related to how the container works in AWS Lambda. For the first call (cold start lambda) the Firestore client is initialized and the data is written properly, if I do a second try right after, it works fine because the lambda is "warm".
After that I wait ~5 minutes and try to post again, I got an error almost 100% of the times, this when I was the only one using the dev environment.
It looks like the persisted connection/or connection pool from Firestore is not being reused or not being able to be reused after the lambda function has no activity for a few minutes.
Then I try setting the provisioned concurrency for Lambda to try and keep it "warm".. after waiting 5 minutes and trying again I got a different problem, a timeout.
It looks like the connection pooling developed doesn't work very well in a serverless environment with ephemeral containers.
Also, for sure you cannot create the firestore client outside of your lambda handler if you're using AWS lambda. The client must be created fresh for every request. The way lambda "freeze-dries" your lamdba functions when they go into a cold state will break all socket connections which will mess up the state for the firestore client (in my experience). I've had similar problems with Winston for logging and the solution is to initialize whatever object has the network connections inside of the lambda.
Thanks
Il giorno mer 20 mag 2020 alle 14:26 Jonathan Stucklen <
notifications@github.com> ha scritto:
Also, for sure you cannot create the firestore client outside of your
lambda handler if you're using AWS lambda. The client must be created fresh
for every request. The way lambda "freeze-dries" your lamdba functions when
they go into a cold state will break all socket connections which will mess
up the state for the firestore client (in my experience). I've had similar
problems with Winston for logging and the solution is to initialize
whatever object has the network connections inside of the lambda.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#692 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADEOXWXKIJYNYZN3PYOJ3M3RSPD5RANCNFSM4GMSOCZQ>
.
I am also having the same issue while doing smile query on firestore, { Error: 14 UNAVAILABLE: DNS resolution failed at Object.exports.createStatusError (/node_modules/grpc/src/common.js:91:15) at ClientReadableStream._emitStatusIfDone (/node_modules/grpc/src/client.js:233:26) at ClientReadableStream._readsDone (/node_modules/grpc/src/client.js:199:8) at /node_modules/grpc/src/client_interceptors.js:683:15
This bug was originally filed as a problem with the grpc library, which is now unsupported. If you are experiencing this error with that library, please upgrade to @grpc/grpc-js. If you experience this erorr with @grpc/grpc-js, please file a separate issue with that information.
Activity
kyle-mccarthy commentedon Jan 4, 2019
I am having this same issue on Google App Engine standard, node 10.
I am using @google-cloud/logging-winston which depends on @google-cloud/logging and that depends on @google-cloud/common-grpc which uses this package. So I can't say what is causing this issue.
Is this a problem with this package or how other packages implement it?
sergioregueira commentedon Jan 8, 2019
Related issue: googleapis/google-cloud-node#2438
murgatroid99 commentedon Jan 18, 2019
The status responses described here are expected behavior of gRPC itself. Generally, we expect that some responses, including
UNAVAILABLE, should be retried. In these cases the library that uses gRPC should perform the retry logic, as described in that linked issue.sergioregueira commentedon Jan 18, 2019
@murgatroid99 the problem is gRPC library does not reconnect after that error, so applications stop sending logs to Stackdriver. When this happens, we have to replace the affected instance with a new one.
murgatroid99 commentedon Jan 18, 2019
First, to make sure that we're on the same page, the way gRPC reconnection is supposed to work is that if a connection fails, then the next time the user starts a call the library starts trying to reestablish the connection. A user that retries failed
UNAVAILABLErequests should trigger that reconnection.So, are you saying that the Stackdriver library is retrying the failed request after the connection drops, and when it does so the gRPC library never reestablishes the connection? If so, that is a major bug that we are otherwise unaware of, so please file a full bug report with reproduction steps.
nicolasnoble commentedon Jan 18, 2019
Emphasis on "if the library is retrying the failed request". The initial bug report seems to indicate this isn't the case.
alexander-fenster commentedon Jan 31, 2019
To add some details here. Client libraries use gRPC via the gax layer, and that gax layer can send retries if the library is configured so. By 'configured so' I mean the JSON configuration file that is passed to client library constructor. If this file mentions that the given method is idempotent - i.e. it is safe to retry it - gax layer will do the retries. If it's non-idempotent, just like all POST methods, it won't be retried automatically and it should be taken care of by the caller.
In logging library, the configuration file is here. @crwilcox made a change 2 weeks ago to treat all the logging method as idempotent, which means that you might get a duplicated log line in case of a retry, but you should not get fails: googleapis/nodejs-logging#366 It does not fix the TCP error that makes gRPC fail, but at least it should make gax retry the failed call (we are now talking only about logging libraries).
Let us make a new release of the logging library, it should fix most of the problems related to logging libraries. For other libraries, let's go one by one and see what's going on, but in general, the caller code should be ready to get
UNAVAILABLE(it's a network, so any call can technically fail), and retryingUNAVAILABLEfor non-idempotent methods is something your code should take care of.sergioregueira commentedon Feb 1, 2019
@murgatroid99 @nicolasnoble I am sorry for the delay. I was a bit busy these days.
The same day you asked me for more information, I enabled gRPC debugging setting some environment variables (
GRPC_TRACE=tcp GRPC_VERBOSITY=DEBUG) and I monitored the logs during several days.I could check, as you mentioned, that
nodejs-loggingtries to reconnect automatically when something fails. This is an example where it reconnects successfully (and logs continue being persisted):Nevertheless, I found some cases where the reconnection was not completed (and logs stopped):
I think the change done by @crwilcox will reduce the probability of lost logs due to request errors but the error that I have just detailed will continue happening.
By the way, thanks @alexander-fenster for your clear explanation!
sergioregueira commentedon Feb 1, 2019
More examples where it does not reconnect:
crwilcox commentedon Feb 1, 2019
I released a new version of the
@google-cloud/loggingpackage that will now retry when writing log entries onUNAVAILABLE. https://www.npmjs.com/package/@google-cloud/logging/v/4.3.0For operations deemed non-idempotent, such as the case with things like
WriteLogEntries, the RPC call that underlies many logging calls, it isn't necessarily safe for the client to retry. A decision was made in this case that duplicated logs are preferable to not logging. There unfortunately will exist other non-idempotent RPCs that will be more complicated.murgatroid99 commentedon Feb 1, 2019
@sergioregueira When you say that the logs ceased, do you mean that in each case, that is the last log line output from that process, and that the other logs come from different processes? If so, what is the behavior of those processes after they stop outputting logs?
Also, I don't know exactly what behavior of the gRPC library we are seeing here, but the expected behavior is not that the library always reconnects; it generally only reconnects if there is an existing pending request. Do any of the logs you have show that it is failing to reconnect while there is a pending request. If not, you may need to get more trace information to see that information. The
apitracer should help, so you can modify the environment variables to haveGRPC_TRACE=api,tcp. The full list of available tracers is in this document.sergioregueira commentedon Feb 1, 2019
@murgatroid99 I mean the application continues working properly but Stackdriver does not process more logs of the affected instance (including gRPC traces). Logs generated automatically (ie.
appengine.googleapis.com/request_log) are not interrupted.When that error happens I have to delete the affected instance because the logs generated by that instance after the error are not registered.
The logs I attached in my previous post is all I could obtain after the errors. I will update right now that environment variable to get more information. If you have additional suggestions to debug the problem just let me know.
murgatroid99 commentedon Feb 1, 2019
I just want to make sure I am understanding this correctly. You are using the Stackdriver logger to save the gRPC logs generated from that same Stackdriver logger, which you are using to debug why the logger is failing?
sergioregueira commentedon Feb 1, 2019
@murgatroid99
On the one hand, our application logs are sent to Stackdriver via
nodejs-logging(that uses internally gRPC) in a structured way (usingLogEntry.jsonPayloadobject).On the other hand, gRPC logs are printed by the library itself to
stdout/stderr(we did not have to code anything) and collected automatically by Stackdriver (as simpleLogEntry.textPayloadstring).In conclusion, we use logs that are NOT sent via gRPC to debug gRPC protocol.
murgatroid99 commentedon Feb 1, 2019
Actually, it would probably help the most to run with
GRPC_TRACE=all. That will tell us with the greatest granularity possible the very last things the gRPC library does before we stop getting logs.15 remaining items
orgads commentedon Mar 27, 2020
I suppose you refer to #1199? It did not fix this issue.
Subchannel: Avoid reconnecting when network is unreachable
murgatroid99 commentedon Mar 31, 2020
@orgads I think I was actually referring to #1251. I don't think #1199 is related to the problems reported here at all.
stefanotauriello commentedon May 19, 2020
I'm using it in AWS Lambda, how can I fix it?
stuckj commentedon May 20, 2020
Also, for sure you cannot create the firestore client outside of your lambda handler if you're using AWS lambda. The client must be created fresh for every request. The way lambda "freeze-dries" your lamdba functions when they go into a cold state will break all socket connections which will mess up the state for the firestore client (in my experience). I've had similar problems with Winston for logging and the solution is to initialize whatever object has the network connections inside of the lambda.
stefanotauriello commentedon May 20, 2020
ming2020 commentedon Jun 1, 2020
Try reducing
grpcto 1.22.2raghuchahar007 commentedon Jul 8, 2020
I am also having the same issue while doing smile query on firestore,
{ Error: 14 UNAVAILABLE: DNS resolution failed at Object.exports.createStatusError (/node_modules/grpc/src/common.js:91:15) at ClientReadableStream._emitStatusIfDone (/node_modules/grpc/src/client.js:233:26) at ClientReadableStream._readsDone (/node_modules/grpc/src/client.js:199:8) at /node_modules/grpc/src/client_interceptors.js:683:15Version:
firebase-admin: 7.0.0
Node: 6.X
Please help!
alexander-fenster commentedon Jul 8, 2020
@raghuchahar007 what's your gRPC versions? Please post the output of
npm ls grpc @grpc/grpc-js google-gax.grahamjenson commentedon Jul 16, 2020
We have a similar issue and by putting in the
.npmrcputI am hoping to find a way to do this without rebuilding, but this is my best guess.
dooleyb1 commentedon Aug 28, 2020
Resolved personally by updating node modules FROM:
TO:
mayankpunetha007 commentedon Oct 6, 2021
Having the same problem with:
"@grpc/grpc-js": "^1.3.7",
"@grpc/proto-loader": "^0.6.5"
Setup is:
Local Node Server ---HTTPS----> Google Load Balancer ------HTTP2----> GRPC backend
Always getting:
Error: 14 UNAVAILABLE: Connection dropped
Any luck with this for anyone else?
murgatroid99 commentedon Apr 1, 2025
This bug was originally filed as a problem with the
grpclibrary, which is now unsupported. If you are experiencing this error with that library, please upgrade to@grpc/grpc-js. If you experience this erorr with@grpc/grpc-js, please file a separate issue with that information.