Replies: 35 comments 16 replies
-
You don’t need to await on Is the NodeAddress reachable from the phone/computer you are using? Keep in mind that iOS blocks non-https (i.e. http) traffic for example. Android may do something similar... You can try hitting the host directly to test the link. |
Beta Was this translation helpful? Give feedback.
-
@ricmoo Thanks for the assistance. The issue is the non-https blocking like you mentioned. |
Beta Was this translation helpful? Give feedback.
-
@ricmoo am still having this issue in Expo. After setting the node behind a HTTPS proxy and verifying that I can hit the host directly with the link, using ethers to connect still gives this error. Is there anything else I can try? |
Beta Was this translation helpful? Give feedback.
-
What is the error? |
Beta Was this translation helpful? Give feedback.
-
Still |
Beta Was this translation helpful? Give feedback.
-
(oh of course, I checked the issue body and not the title... My bad. :p) What do you get if you change that provider call to: const result = await ethers.utils.fetchJson(NodeAddress, '{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }')
console.log(result); |
Beta Was this translation helpful? Give feedback.
-
Here is the full promise rejection. I just tested outside of Expo and it works normally. Perhaps a shim issue? |
Beta Was this translation helpful? Give feedback.
-
We're getting closer, I think. Looks like the response isn't JSON, so we'll go one further bit up. Try this: const result = await ethers.utils._fetchData({
url: NodeAddress,
headers: { "content-type": "application/json" },
},
ethers.utils.toUtf8Bytes('{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }')
);
console.log("Binary", result);
console.log("Text", ethers.utils.toUtf8String(result)); |
Beta Was this translation helpful? Give feedback.
-
The output is
As far as I can tell that request isn't throwing an error. |
Beta Was this translation helpful? Give feedback.
-
So, that means the response from the link is working. It is just returning zero bytes... Which is invalid JSON. :) Is the backend a normal Node? Maybe there is a problem with the proxy? |
Beta Was this translation helpful? Give feedback.
-
When I try that method outside of expo it returns this
It must be an expo specific problem. Maybe the response isn't able to be parsed properly. |
Beta Was this translation helpful? Give feedback.
-
The backend is a geth node. |
Beta Was this translation helpful? Give feedback.
-
Are there any flags on the geth node that need to be set? |
Beta Was this translation helpful? Give feedback.
-
I think there may be. Depending on your setup (again, if you are using a proxy, things might further be affected), but you might want to adjust the network device to be any (I think you do this by specifying If it is using CORS, make sure your Proxy is set up to forward Setting up a link is definitely non-trivial... |
Beta Was this translation helpful? Give feedback.
-
This may be related to #1320. I'm trying to debug the RN universe right now. Can you include the version of |
Beta Was this translation helpful? Give feedback.
-
Derp, re-read your docs, was missing |
Beta Was this translation helpful? Give feedback.
-
Hey @daihovey, the error
If you're still facing this, are you in browser or node? In the browser, you'll be able to see network logs. You also get |
Beta Was this translation helpful? Give feedback.
-
Changing the ethers version to 5.0.5 doesn't solve it for me. 🤦♂️
but on macOS I get the error message, everyone else is getting
Does anyone have any light on the situation? any sort of workaround? |
Beta Was this translation helpful? Give feedback.
-
I have the same issue but only when use webpack. Without webpack If I run win nodemon xxx.ts, works perfectly. |
Beta Was this translation helpful? Give feedback.
-
Some other possibilites that could causes that error:
|
Beta Was this translation helpful? Give feedback.
-
I'm also seeing a similar error. Gory details below... Axios post works
|
Beta Was this translation helpful? Give feedback.
-
this is my code:
I have this error:
I searched a lot in the internet but still couldn't find any solution |
Beta Was this translation helpful? Give feedback.
-
Has anyone encountered this error while running Cypress for e2e testing? Currently working through it and curious if anyone would have any insight on this. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using ether and alchemy as provider. everything was working fine until 3 weeks ago. from that time on I get network error:
this is my code:
I curl the direct API from alchemy and it works. Do you have any idea? |
Beta Was this translation helpful? Give feedback.
-
Hey, for anyone that having this issue recently, see my answer here: rainbow-me/rainbowkit#843 (comment) |
Beta Was this translation helpful? Give feedback.
-
change the api in _app.tsx to your infura api and your good to go! no more errors! solved |
Beta Was this translation helpful? Give feedback.
-
I had this issue with webpack. The solution was mentioned here: #3536 (comment) Instead of new providers.JsonRpcProvider(config.rpcEndpoint); call new providers.JsonRpcProvider({
url: config.rpcEndpoint,
skipFetchSetup: true,
}); |
Beta Was this translation helpful? Give feedback.
-
This error happens because Ganache is connected to different environment. Go to the Ganache and click on Settings, then go the server and choose -vEthernet(WSL) as server. After this save and restart the Ganache. In your connection code replace it with the Ganache server network you selected. i.e
|
Beta Was this translation helpful? Give feedback.
-
Do u include |
Beta Was this translation helpful? Give feedback.
-
So i solved my issue with this code first i wrote a proxy script to check the headers sent by react native expo. the headers were 'content-type': 'application/json',
'content-length': '60',
host: '192.168.178.29:3000',
connection: 'Keep-Alive',
'accept-encoding': 'gzip',
'user-agent': 'okhttp/4.9.2' after removing host header it worked. so i wrote this CustomJsonRpcProvider. Now it works async fetchFunc(path: string, json: string) {
try {
const response = await fetch(
this.connection.url,
{
method: 'POST',
body: json,
headers: {
...this.connection.headers, //by default ethers sets host header and bellecour rpc node rejects it
'Content-Type': 'application/json'
},
}
);
if (!response.ok) {
throw new Error('Bad response from server');
}
return await response.json();
} catch (error) {
throw error;
}
}
}
const provider = new CustomJsonRpcProvider(RPCUrl); |
Beta Was this translation helpful? Give feedback.
-
Here is my code being used for testing. It works in a small node program but will not work in React Native.
Beta Was this translation helpful? Give feedback.
All reactions