The following code works on Node's v10.15.3 version:
const { post } = require('request');
post({
url: 'https://cidadao.sinesp.gov.br/sinesp-cidadao/mobile/consultar-placa/v4',
body: '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<v:Envelope xmlns:v=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <v:Header>\n <b>LGE Nexus 5</b>\n <c>ANDROID</c>\n <d>v4</d>\n <e>4.3.2</e>\n <f>98.193.54.223</f>\n <g>514650d8dba4784ed08b5a029583576361a50bc5</g>\n <h>-3272.3179572637086</h>\n <i>940.839492700698</i>\n <j/>\n <k/>\n <l>2019-05-24 10:24:35</l>\n <m>8797e74f0d6eb7b1ff3dc114d4aa12d3</m>\n </v:Header>\n <v:Body xmlns:n0=\"http://soap.ws.placa.service.sinesp.serpro.gov.br/\">\n <n0:getStatus>\n <a>LSU3J43</a>\n </n0:getStatus>\n </v:Body>\n</v:Envelope>',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'User-Agent': 'SinespCidadao / 3.0.2.1 CFNetwork / 758.2.8 Darwin / 15.0.0',
Host: 'cidadao.sinesp.gov.br'
},
}, (err, httpResponse, body) => {
if (err) return console.error(err);
console.log(JSON.stringify(httpResponse));
});
But after upgrading to v12.2.0 or above I got the following error:
Error: write EPROTO 17432:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:c:\ws\deps\openssl\openssl\ssl\statem\statem_lib.c:1922:
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:83:16) {
errno: 'EPROTO',
code: 'EPROTO',
syscall: 'write'
}
How can I fix it?
As the same code works on Node.js v10.15.3, but not work on v12.2.0, and the error message indicates "unsupported protocol", the most possible root cause of this issue is: the minimal supported TLS version in Node.js 10 is TLSv1.0, but since v11.4.0, it is raised to TLSv1.2 (tls.DEFAULT_MIN_VERSION). I suspect the certificate of cidadao.sinesp.gov.br is signed with TLSv1.0, which works on Node.js v10.15.3, but not on v12.2.0.
To make Node.js accept TLSv1.0, you can lauch Node.js process with --tls-min-v1.0 option.
I made an experiment and it works well:
BTW, the certificate of cidadao.sinesp.gov.br is invalid now. It has been expired since May 2018 -- as the OP mentioned, the request should be sent from Brazil (or through proxy node in Brazil).
Related
When trying to run truffle migrate --network bsc, truffle usually (not always) manages to deploy the migrations contract, then fails with an error: header not found.
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({ code: -32000, message: 'header not found' })
at new NodeError (node:internal/errors:363:5)
at Web3ProviderEngine.emit (node:events:354:17)
at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:54:14
at afterRequest (D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:148:21)
at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:174:21
at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:232:9
at D:\Contracts\novaria\node_modules\async\internal\once.js:12:16
at replenish (D:\Contracts\novaria\node_modules\async\internal\eachOfLimit.js:61:25)
at D:\Contracts\novaria\node_modules\async\internal\eachOfLimit.js:71:9
at eachLimit (D:\Contracts\novaria\node_modules\async\eachLimit.js:43:36)
at D:\Contracts\novaria\node_modules\async\internal\doLimit.js:9:16
at end (D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:211:5)
at Request._callback (D:\Contracts\novaria\node_modules\web3-provider-engine\subproviders\rpc.js:70:28)
at Request.self.callback (D:\Contracts\novaria\node_modules\request\request.js:185:22)
at Request.emit (node:events:365:28)
at Request.<anonymous> (D:\Contracts\novaria\node_modules\request\request.js:1154:10)
at Request.emit (node:events:365:28)
at IncomingMessage.<anonymous> (D:\Contracts\novaria\node_modules\request\request.js:1076:12)
at Object.onceWrapper (node:events:471:28)
at IncomingMessage.emit (node:events:377:35)
at endReadableNT (node:internal/streams/readable:1312:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Here's the config for bsc network:
bsc: {
provider: () => { return new HDWalletProvider(mnemonic, `https://bsc-dataseed2.binance.org/`)},
network_id: 56,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true,
},
compilers: {
solc: {
version: "0.8.7", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
settings: { // See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: true,
runs: 200
},
Deploying to testnet and development works without issue. I have in the past deployed to bsc with truffle (been a while though). I've tried changing RPC urls, and messed around with timeout and confirmations (pretty sure that doesn't make a difference for this error). After searching the internet for solutions, the only answer that seems to have worked for people is to change the RPC, but I haven't had any luck with that. Does anyone have any suggestions?
I had the same problem today. Fixed it by using the Websocket endpoint wss://bsc-ws-node.nariox.org:443 from the smart chain docs https://docs.binance.org/smart-chain/developer/rpc.html
Using Node.js and cross-fetch, I receive an error accessing an HTTPS site (see title and comments below). There is no proxy involved. The code below is a simplified version that reproduces the error. The comments in the code contain the exact error text.
This had been working until something (?) changed, which leads me to believe a server-side change, which I have no access to. However, Tampermonkey JS scripts that do the same requests using GM_xmlhttpRequest still work correctly.
Any debugging suggestions, or why the "wrong version number" is generated?
Edit: looking in the debugger at the call to tlssock.connect(options, tlssock._start); the 'ciphers' option is set to ciphers: "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA" and the 'port' option is 443. In the TLSSocket member, I didn't see anything that jumped out at me relating to a version number.
const fetch = require('cross-fetch');
const testURL = 'https://api.torn.com/faction/?selections=upgrades&key=xxxxxxxxxx';
fetch(testURL).then(res => {
console.log('[TEST] res: ', res);
}).then(data => {
console.log('[TEST] data: ', data);
}).catch(err => {
console.error("[TEST] error: ", err);
});
/*
Output:
[TEST] error: FetchError: request to https://api.torn.com/faction/?selections=upgrades&key=xxxxxxxxxx failed,
reason: write EPROTO 140735681590144:
error:1408F10B:SSL routines:ssl3_get_record:
wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
at ClientRequest.<anonymous> (/Users/edlau/Documents/Torn-JS/Fac-chat-generic/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (events.js:400:28)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
type: 'system',
errno: 'EPROTO',
code: 'EPROTO'
}*/
Edit 2: I updated node.js to the latest, with the same results, versioning info is as follows:
npm version
{
facchat: '2.0.0',
npm: '8.3.0',
node: '17.3.0',
v8: '9.6.180.15-node.12',
uv: '1.42.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '102',
nghttp2: '1.45.1',
napi: '8',
llhttp: '6.0.4',
openssl: '3.0.1+quic',
cldr: '40.0',
icu: '70.1',
tz: '2021a3',
unicode: '14.0',
ngtcp2: '0.1.0-DEV',
nghttp3: '0.1.0-DEV'
}
Edit 3: Using CURL (to the same URL):
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
After playing with this for hours, reducing it to just using curl and various options, none of which worked - it finally did again. With no options. My test code works as well now. So I conclude that it was server side 'maintainance' going on, or being routed to different servers, the server is hosted, near as I can tell, in a cloudflare environment.
So although I can't say for certain what was causing this, I can no longer reproduce it.
I try to login a dummy user with the firebase js sdk localy. I have the default firebase emulator running. After calling the function i get following exception:
Error: Headers X-Client-Version forbidden
at dispatchError (C:\Users\user\Documents\Projekte\Backend\functions\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:62:19)
at validCORSPreflightHeaders (C:\Users\user\Documents\Projekte\Backend\functions\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:99:5)
at Request.<anonymous> (C:\Users\user\Documents\Projekte\Backend\functions\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:367:12)
at Request.emit (events.js:315:20)
at Request.onRequestResponse (C:\Users\user\Documents\Projekte\Backend\functions\node_modules\request\request.js:1059:10)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:641:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at Socket.socketOnData (_http_client.js:509:22)
at Socket.emit (events.js:315:20) undefined
at VirtualConsole.<anonymous> (node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:65:53)
at validCORSPreflightHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:99:5)
at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:367:12)
at Request.onRequestResponse (node_modules/request/request.js:1059:10)
console.log
t {
code: 'auth/network-request-failed',
message: 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.',
a: null
}
at Object.<anonymous> (test/test.ts:275:12)
If i try to connect to my online project it works fine, but i want to perform my testing localy with the emulator.
Example Code:
const app = firebase.initializeApp(firebaseConfig);
app.auth().useEmulator("http://localhost:9099");
app.firestore().settings({
host: "localhost:8080",
ssl: false,
});
test('Example test case', async () => {
try {
const cred: UserCredential = await app.auth().signInWithEmailAndPassword("foo#bar.de", "bla2377");
expect(cred).toBeTruthy();
expect(cred.user).toBeTruthy();
} catch (e) {
console.log(e);
expect(true).toBeFalsy();
}
});
Enviorment Informations:
Operating System version: Windows 10 Home 10.0.18363 Build 18363
Firebase SDK version: 8.2.3
Jest Version: 26.6.3
Node Version: 14
jsdom doesn't support wildcard access-control-allow-headers, which are used by firebase. This answer fixes the exception.
I am new to node.js, I use request send the post request.but I got a error!
request({
method: 'POST',
url: config.api + '/index',
body: {
name: "name"
},
json: true
})
throw er; // Unhandled 'error' event
^
Error: Invalid protocol: 127.0.0.1:
I write this: It work fine, you can modify it like this.
request({
method: 'POST',
url: 'http://127.0.0.1:3000' + '/index',
body: {
name: "name"
},
json: true
})
Your code is incorrect: follow the instructions on the NPM module page.
If you're using a PHP Development Server please refer to this thread for the solution.
Stack Overflow
I met a similar issue on Win10 after a system update. It was caused by the system proxy settings.
http_proxy=127.0.0.1:8888
https_proxy=127.0.0.1:8888
Change the above environment settings to
http_proxy=http://127.0.0.1:8888
https_proxy=http://127.0.0.1:8888
done the job for me.
Btw, if you use git-bash, you can also check the git config.
$git config --list
...
http.sslverify=false
http.proxy=http://127.0.0.1:8888
https.proxy=http://127.0.0.1:8888
...
I'm building an app using Mailjet, and using their connection example.
app.get('/send',function(req,res){
...
var request = mailjet
.post("send")
.request({
<request stuff, email details>
});
request
.on('success', function (response, body) {
<handle response>
})
.on('error', function (err, response) {
<handle error>
});
Getting this error:
Unhandled rejection Error: Unsuccessful
at /home/ubuntu/workspace/node_modules/node-mailjet/mailjet-client.js:203:23
When I go to the Mailjet client and ask it to log the error, it tells me:
{ [Error: Unauthorized]
original: null,
...
Anyone have an idea of where I should start troubleshooting?
Update: saw this in the error output:
header:
{ server: 'nginx',
date: 'Thu, 02 Mar 2017 14:04:11 GMT',
'content-type': 'text/html',
'content-length': '20',
connection: 'close',
'www-authenticate': 'Basic realm="Provide an apiKey and secretKey"',
vary: 'Accept-Encoding',
'content-encoding': 'gzip' },
So it's not eating my API key and secret. Can anyone tell me how to set those as environmental variables in Cloud9?
You can set environment variables in ~/.profile. Files outside of the workspace directory /home/ubuntu/workspace aren't accessible for read-only users so people won't be able to see them.
In the terminal, you can do for example:
$> echo "export MAILJET_PUBLIC=foo" >> ~/.profile
$> echo "export MAILJET_SECRET=bar" >> ~/.profile
Then, you'll be able to access those variables in Node when using the connect method:
const mailjet = require ('node-mailjet')
.connect(process.env.MAILJET_PUBLIC, process.env.MAILJET_SECRET)
The runners (from the "run" button) and the terminal will evaluate ~/.profile and make the environment variable available to your app.