I've been working on a Node.js project that accesses the google cloud api. When I'm in an external network the request works fine and I'm receiving the expected answer. Yet when I'm behind my cooperate proxy, which is necessary to access our smpt server, I receive the following error:
Auth error:Error: read ECONNRESET
To get through the cooperate proxy I'm using cntlm and I've set it as the environment proxy as mentioned in this article.
Furthermore I've enabled GRPC verbosity and GRPC handshake trace as seen in the code below.
process.env.GRPC_VERBOSITY = 'DEBUG'
process.env.GRPC_TRACE = 'handshaker'
process.env.HTTP_PROXY = 'http://127.0.0.1:3128'
process.env.http_proxy = 'http://127.0.0.1:3128'
process.env.https_proxy = 'http://127.0.0.1:3128'
process.env.HTTPS_PROXY = 'http://127.0.0.1:3128'
process.env.PROXY = 'http://127.0.0.1:3128'
process.env.proxy = 'http://127.0.0.1:3128'
// Imports the Google Cloud client library
const language = require('@google-cloud/language');
// Instantiates a client
const client = new language.LanguageServiceClient({
projectId:'CNL-Showcase',
keyFilename: 'path/to/file/creds.json'
});
const document = {
content: request,
type: 'PLAIN_TEXT',
language: 'DE',
encodingType: 'UTF-8'
};
console.log('sending to Google Api');
client
.analyzeEntities({ document: document })
.then((results: any) => {
...
}).catch((err: any) => {
console.error('ERROR:', err);
res.send(err);
});
Note: The path to my creds file is changed on purpose, as mentioned above if I'm not behind a proxy it works just fine.
The console output looks as follows:
D0809 09:49:45.850000000 3460 dns_resolver.cc:339] Using native dns resolver
sending to Google Api
D0809 09:49:46.039000000 3460 dns_resolver.cc:280] Start resolving.
I0809 09:49:46.069000000 3460 handshaker.cc:141] handshake_manager
000000000423BE30: adding handshaker http_connect [0000000
00286BDD0] at index 0
I0809 09:49:46.073000000 3460 handshaker.cc:141] handshake_manager
000000000423BE30: adding handshaker security [00000000028
6AE00] at index 1
I0809 09:49:46.076000000 3460 handshaker.cc:212] handshake_manager
000000000423BE30: error="No Error" shutdown=0 index=0, ar
gs={endpoint=0000000002868FA0, args=00000000028617C0 {size=9:
grpc.primary_user_agent=grpc-node/1.13.1, grpc.client_channel_f
actory=000007FEEA85EBA0, grpc.channel_credentials=000000000423C960,
grpc.server_uri=dns:///language.googleapis.com:443, grpc.
http_connect_server=language.googleapis.com:443,
grpc.default_authority=language.googleapis.com:443, grpc.http2_scheme=https,
grpc.security_connector=00000000028F54E0,
grpc.subchannel_address=ipv4:127.0.0.1:3128}, read_buffer=0000000002876860
(length
=0), exit_early=0}
I0809 09:49:46.081000000 3460 handshaker.cc:253] handshake_manager
000000000423BE30: calling handshaker http_connect [000000
000286BDD0] at index 0
I0809 09:49:46.083000000 3460 http_connect_handshaker.cc:300] Connecting to
server language.googleapis.com:443 via HTTP prox
y ipv4:127.0.0.1:3128
I0809 09:49:46.211000000 3460 handshaker.cc:212] handshake_manager
000000000423BE30: error="No Error" shutdown=0 index=1, ar
gs={endpoint=0000000002868FA0, args=00000000028617C0 {size=9:
grpc.primary_user_agent=grpc-node/1.13.1, grpc.client_channel_f
actory=000007FEEA85EBA0, grpc.channel_credentials=000000000423C960,
grpc.server_uri=dns:///language.googleapis.com:443, grpc.
http_connect_server=language.googleapis.com:443,
grpc.default_authority=language.googleapis.com:443, grpc.http2_scheme=https,
grpc.security_connector=00000000028F54E0,
grpc.subchannel_address=ipv4:127.0.0.1:3128}, read_buffer=0000000002876860
(length
=0), exit_early=0}
I0809 09:49:46.211000000 3460 handshaker.cc:253] handshake_manager
000000000423BE30: calling handshaker security [0000000002
86AE00] at index 1
I0809 09:49:46.303000000 3460 handshaker.cc:212] handshake_manager
000000000423BE30: error="No Error" shutdown=0 index=2, ar
gs={endpoint=000000000287A7F0, args=0000000002862720 {size=10:
grpc.primary_user_agent=grpc-node/1.13.1, grpc.client_channel_
factory=000007FEEA85EBA0, grpc.channel_credentials=000000000423C960,
grpc.server_uri=dns:///language.googleapis.com:443, grpc
.http_connect_server=language.googleapis.com:443,
grpc.default_authority=language.googleapis.com:443, grpc.http2_scheme=https
, grpc.security_connector=00000000028F54E0,
grpc.subchannel_address=ipv4:127.0.0.1:3128,
grpc.auth_context=000000000285DD60},
read_buffer=0000000002876860 (length=0), exit_early=0}
I0809 09:49:46.304000000 3460 handshaker.cc:240] handshake_manager
000000000423BE30: handshaking complete -- scheduling on_h
andshake_done with error="No Error"
I0809 09:49:46.305000000 3460 subchannel.cc:608] New connected subchannel at
0000000002867790 for subchannel 00000000028A027
0
Auth error:Error: read ECONNRESET
Auth error:Error: read ECONNRESET
Auth error:Error: read ECONNRESET
Auth error:Error: read ECONNRESET
Auth error:Error: read ECONNRESET
Auth error:Error: read ECONNRESET
I cannot identify what causes the issue as the handshake seems to work just fine.