-
Notifications
You must be signed in to change notification settings - Fork 94
Cannot connect to local node from host but can from external #881
Comments
But I can connect from external machine wn.mp4Please fix this bug |
To reproduce Please install Debian 11 Bullseye from fresh. Make sure
Install Nodejs v17 and near API cli Install Rust 1.56 (and maybe more system dependencies) and run local near-indexer 1.22 If it work show video |
specifying po.mp4 |
@evergreen-trading-systems |
That was a typo but it doesn't change anything because if it was working, it would say |
@nikurt since you are working a lot with local nodes, maybe you can suggest something here? |
Is the video in the description is taken on a Windows machine? |
Yes there are 2 machines, windows and debian. I can connect from windows to debian. Also from debian but using |
Actually, my crazy idea seems to be correct.
|
@evergreen-trading-systems Line 48 in 6931906
|
@evergreen-trading-systems I was able to reproduce your issue actually.. @volovyk-s I'm not sure exactly what's going on, but I think it has something to do with the use of import fetch from 'node-fetch';
import http from 'http';
import https from 'https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
function agent(_parsedURL) {
if (_parsedURL.protocol === 'http:') {
return httpAgent;
} else {
return httpsAgent;
}
}
function fetch2(resource, init) {
return fetch(resource, {
agent: agent(new URL(resource.toString())),
...init,
});
}
let json = null;
console.log(await fetch2("http://localhost:3030", {
method: json ? 'POST' : 'GET',
body: json ? json : undefined,
headers: { 'Content-Type': 'application/json; charset=utf-8' }
})); This is basically what is in https://github.com/near/near-api-js/blob/master/src/utils/setup-node-fetch.ts and I get the same error, so there seems to be some problem with that. |
@volovyk-s I took another look at this, and I'm quite sure it's the same as this issue: nodejs/node#40702 The reproducer given in that issue seems to work on Debian 10 but fails on Debian 11, also the snippet in this comment gives an IPv4 addr on Debian 10 but an IPv6 one on Debian 11: In that case I think changing near-cli to use |
Thanks @marcelo-gonzalez ! Let's ask @evergreen-trading-systems to double-check if it will work. I'm afraid that |
Could you elaborate why? Because actually changing The reason why it's working with |
Given that all IP addresses in the protocol are IPv4-only, such as node's rpc_addr and network peer addresses - it totally makes sense to me to have IPv4-only addresses in near-cli |
reopening #873
OS:
Debian 11
Can you explain this. Why is
http://localhost:3030/status
success andNEAR_ENV=local near state local.test
failnw.mp4
The text was updated successfully, but these errors were encountered: