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,
});
Related
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
I'm using npm got package to do web scraping and I want to use a SOCKS proxy. The docs have this snippet about using proxies:
import got from 'got';
import {HttpsProxyAgent} from 'hpagent';
await got('https://sindresorhus.com', {
agent: {
https: new HttpsProxyAgent([skipped by me])
}
});
So I've tried using socks-proxy-agent, but apparently the agent property of got only supports http, https and http2 keys.
How do I make got use my SOCKS agent?
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 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.
I'm running Debian 6 with NodeJS6 and request-promise.
I'm using request-promise to deliver web hooks. Currently, we are delivering around 2+M web hooks each day.
Most of the time everything runs fine, but there are cases where the HTTP request simply isn't delivered.
This is my simple code:
requestPromise({ url: 'https://change-iot-request/do', auth: { user: "switch", pass: "my-password" }, method: "GET", timeout: 15000, rejectUnauthorized: false})
.catch(function(err) {
console.log(err);
});
Sometimes the endpoint simply doesn't receive anything.
I've tried to run tshark to see if packages came through - nothing on any of the servers.
If I when it occurs run curl command with the same parameters the request DOES come through.
And if I restart the NodeJS it starts to deliver correctly again.
This is the error output:
{"name":"RequestError","message":"Error: ETIMEDOUT","cause":{"code":"ETIMEDOUT","connect":true},"error":{"code":"ETIMEDOUT","connect":true}
What to do?
Especially when curl does work so the connection should be fine.
it can be a lot of causes, maybe it's not node fold at all
ETIMEDOUT means that your server do not get response for request
you can try set a timeout, something like
var rp = require('request-promise');
var reqPromise = rp({
method: 'get',
uri: 'http://localhost:8080/test-connection-length',
timeout: 600000, // 10 min.
resolveWithFullResponse: true
});
or install node-retry and your server will re-run automatically when it's needed