I'm having problem with sending request using TLSv1.1. I've tried many solutions on the internet and no luck. I have to use only TLSv1.1 on specific requests because some of my services are legacy services.
Error: write EPROTO 98230000:error:0A000102:SSL routines:ssl_choose_client_version:unsupported protocol
This is the error I've been facing.
1. I've used axios and set httpsAgent like this.
const axios = require('axios');
const httpsAgent = new https.Agent({
maxVersion: 'TLSv1.1',
minVersion: 'TLSv1.1',
});
const response = await axios.post('URL', payload, { httpsAgent });
2. Bunch of other dependencies and NodeJS https module.
I've tried few dependencies that can send request to API and still getting same error.
3. --tls-min-v1.0' option
Tried NODE_OPTIONS='--tls-min-v1.0' yarn dev still no luck.
OS: Windows 10
NodeJS Version: v18.12.1
Related
i'm using the graphql-request npm package in order to use graphql in my software.
i have the following line in my code:
const client: GraphQLClient = new GraphQLClient(process.env.OCEAN_ENDPOINT, {});
client.setHeaders({ Authorization: `Bearer: ${token}` });
and then i want to fire a request i use:
await client.request(query, variables);
until two days ago my endpoint was an http url, but now it changed to https and from that moment i'm getting this error:
FetchError: request to https://{graphqlEndpoint}/v1/graphql failed, reason: unable to verify the first certificate
has anyone faced this issue before?
NODE_TLS_REJECT_UNAUTHORIZED = "0";
adding this in env worked for me in nextjs project
I have tor installed on my macOS 10.13.6
I want to use it for my axios xhr requests as a proxy but after a lot of searching I'm unable to find any useful resource. I've not configured tor as a proxy for my browsers and I'm not sure if is working after I run it from terminal. Is there any way to use it as I need and to check if works well?
I'm trying with this code but not sure if tor is really used
#!/usr/bin/env node
const axios = require('axios');
const socks = require('socks-proxy-agent');
const httpsAgent = new socks(`socks5://127.0.0.1:9050`);
axios({
method: 'GET',
baseURL: 'https://foo.bar',
url: 'baz/faz',
httpsAgent: httpsAgent,
});
I have been trying to call a web service running in Docker on my machine on port 4801. I can access the service in the browser, via curl and via .NET's HttpClient, but if I try from node.js (either using axios or the native http module) the request fails with status code 501 Not Implemented.
I eventually tracked the problem down to the fact that there is another process, called ServiceLayer.exe (description: "Logitech VC ServiceLayer"), listening on port 4801. How is Docker able to expose my service on that port such that it can be accessed by the methods listed above, but not from node?
Here is a minimal repro:
const axios = require("axios");
axios.get("http://localhost:4801")
.then(response => console.log(response.data))
.catch(error => console.log({
status: error.response.status,
headers: error.response.headers
}));
docker run -p 4801:8000 -d crccheck/hello-world
node test.js
Output:
{
status: 501,
headers: { server: 'websocket-sharp/1.0', connection: 'close' }
}
I am guessing the websocket-sharp bit is potentially significant.
I have a regular Node(v12) http server on App Engine. I switched to http2 with http2.createSecureServer. It works in development, but deploying to App Engine and after the server starts successfully it responds to requests with 502 bad gateway...
I tried to switch to http2.createServer to not use https, and the request never receives a response (forever loading). The last log in App Engine Log Explorer for that request shows:
[error] 27#27: *2 upstream sent no valid HTTP/1.0 header
while reading response header from upstream, client:
169.254.1.1, server: _, request: "GET / HTTP/1.1",
upstream: "http://127.0.0.1:8081/"
It seems like it somehow is expecting http1, but I don't know why. I also don't know why it's on port 8081, I have the port set to 8080.
After spending my day searching Google and their docs for anything on using http2 with App Engine, I'm burnt out. And, their support page says "post on Stack Overflow"..
main.js
const http2 = require('http2');
const fs = require('fs');
const app = new (require('koa'))();
const logger = require('koa-logger');
const bodyParser = require('koa-bodyparser');
const json = require('koa-json');
const cors = require('#koa/cors');
const router = require('./router.js');
const { PORT, HOST, KEY, CERT } = require('./config.js');
app.use(logger());
app.use(bodyParser());
app.use(json());
app.use(cors({ exposeHeaders: 'authorization' }));
app.use(router.routes());
app.use(router.allowedMethods());
const server = http2
.createSecureServer(
{
key: fs.readFileSync(KEY),
cert: fs.readFileSync(CERT),
allowHTTP1: true
},
app.callback()
)
.listen(PORT, () => {
console.log(`Koa HTTP/2 running at https://${HOST}:${PORT}`);
});
app.yaml
runtime: nodejs12
service: api
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
vpc_access_connector:
name:
env_variables:
NODE_ENV: production
PORT:8080
KEY: key.pem
CERT: cert.pem
...
If you want to use HTTP/2 and App Engine together you might consider using Load Balancing with your serverless applications. A 502 Error in Google App Engine might refer to several different possibilities.
Error message BAD_GATEWAY
An error code 502 with BAD_GATEWAY in the message usually indicates that App Engine terminated the application because it ran out of memory. The default App Engine flexible VM only has 1GB of memory, with only 600MB available for the application container.
Error code 502 or 503
App Engine may take a few minutes to respond successfully to requests. If you send a request and get back an HTTP 502, 503, or some other server error, wait a minute and try the request again.
I have already created backend using node js for sigin & signup page. Now I want to connect to node js . But i have no idea how to do that. I want to connect both react native with my node js. Can you help me ?
simply as how we do for web apps.
here is an example of error reporting
export default async function (body) {
console.log(JSON.stringify(body))
const res = await fetch(`${host}/api/report`, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
},
})
const { message } = await res.json()
if (message) return Toast({ message: message });
else return Toast({ message: 'network error' });
}
I have used fetch to send a POST request to my nodejs server
use API tool like postman or other and make your your nodejs APIs works fine and then connect to your React Native app as above.
You can use ngrok to connect Node with react-native. Run this command:
npm i ngrok -g # installing it globally
Then open another terminal. Run:
ngrok http 3000 # the port you are running on node
Then it will show an alternative link that you can use to test with your Node.
Note: if ngrok http 3000 doesn't work, try ngrok http -region us 3000.
The available ones are us, eu, ap, and au. In my case eu worked for me.
Then copy the link generated e.g. http://8074-129-205-124-100.eu.ngrok.io and test your backend if it displays APIs.
If the link works then you can use it with fetch. Uploading json data to send to MongoDB as the case maybe.