-
Notifications
You must be signed in to change notification settings - Fork 2.3k
using infura in truffle and get Error: Invalid JSON RPC response: "" #852
Comments
@dc1996226 Thanks for opening. It looks very similar to this issue at For what it's worth, I see the final transaction in the migration sequence executed successfully on Ropsten here. Will try to reproduce this this week. |
+1 |
2 similar comments
+1 |
+1 |
+1 |
Just leaving a note here - @draugaslt @nklipa13 @atygr - anyone else adding to this thread. This bug is difficult to reproduce and there's some evidence that it's intermittent (see comment in #894). We'd really like to figure out if this is an infura connectivity issue or a problem with migrations logic. Anything you can add here might be helpful. Examples:
|
I've been hit by the same issue, but not on Infura. A project with 4 migration files, all "saving artifacts" work but the last one ends like this:
What is similar to infura is that the node I target is a load balancer in front of 2 parity nodes running a PoA network. (actually, there are 2 networks configured exactly the same, both behave the same way) In this project it is an "always" error. |
@roderik It looks like this might be caused by the HDWallet provider continuing to poll the remote client for blocks after the client disconnects. Does that seem like a plausible description for your case? If so, we now have a simple way of reproducing this behavior and should be able to detect whether or not hdWallet is being used in migrations / close the provider appropriately. |
I am indeed using HDWalletProvider configured like:
You are mentioning a client but I'm a bit confused about what you mean by that. HDWalletProvider polls, so it is an HTTP request that gets a response and then closes the connection. The Parity node and/or the loadbalancer do not stop answering, so polling at any time for new blocks should just work. Going by the error message, usually means that I forgot to turn on ganache when developing, makes me think that in that last phase, it tries to connect to a different network / endpoint. I also tried the network config without the function, similar result. It still hangs, but I do not get the error messages. Digging deeper! |
Already a small observation: I added a console log in HDWalletProvider to log the rpc url used in the constructor. using Seems like the () => form is not such a good idea |
@roderik Ah that's interesting - I was thinking it's possible that Infura occasionally times out or fails to respond because it's under heavy load. Would you be open to testing a possible fix for this? Have published an experimental build that forces truffle to exit after a command is run and would like to see if that short-circuits this problem. It's available by running: npm install -g darq-truffle@roderik
darq-truffle migrate # <-- Example command NB: |
@cgewecke for us the error was removed, but the outcome is the same. |
@Warrantoken Could you describe the outcome? Also if you have a second, could you uninstall the |
@cgewecke as @Warrantoken mentioned, it does not solve the hanging issue. I've found a way for you to trigger this issue, that will make it a lot easier to try and find the root cause. This repo (a token sale) triggers the bug: https://github.com/DataBrokerDAO/dtx-crowdsale-contracts You can trigger it by running: (0 gas, 5s blocktime, Parity-based PoA network)
Explorer: https://explorer.mintnet.settlemint.com/ An observation already, if I enable migration 1_ and 2_ it does not hang. If I enable another one (i did 14_ now) it hangs. |
@cgewecke here is the contract we tried to deploy, its a slightly modified openzepplin erc20 token with crowdsale: |
@Warrantoken That contract looks like it might be Migrations.sol? Have you successfully deployed to Rinkeby or Ropsten? @roderik - I will try out Mintnet, looks amazing. One thing that occurs to me is that Parity has a known issue interacting with web3 (see truffle migrate 15) that can be resolved by running the nodes in |
@roderik May have gotten it to work. Have published (yet another)
Then fix the missing Output cgewecke$ darq-truffle migrate --reset --network mintnet
Using network 'mintnet'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0x51500047ae18688efca1c7ef82887aa6868094ab48c91358861399ce85e8ea8f
Migrations: 0x0a70c9ab017117be5fa6b6d7b587b89ba548eddd
Saving artifacts...
Running migration: 2_deploy_contracts.js
Running step...
Replacing MiniMeTokenFactory...
... 0x5314464d47f70aef8ff7a1e08fc345060a5706e1f1f8e9af6a4bf3a45ee9e1d5
MiniMeTokenFactory: 0x122a0bd157ecf23406ce4851c93b3c23ffa4eeb6
Replacing MultiSigWalletWithDailyLimit...
... 0x25617048235eb8b95769ed2d46c5f2691a0367b7f4a161be32f59bb1c0bf1d95
MultiSigWalletWithDailyLimit: 0x8bc790a583789367f72c9c59678ff85a00a5e5d0
Replacing DTXToken...
... 0x1dec0ea86f06785e4ad540bac931d6fdb8a7dd732f45c3f02028c5fa5fb7e6c4
DTXToken: 0x57a474713701d60a1e3c22e1827bf421f4948006
Replacing TokenSale...
... 0xc66a183e36369be5680b47fc90b17fa83510af1a0084c15b1682f5e1cf002773
TokenSale: 0x026950f443feb8be15bf0a3b878ba1fe23e0ab61
... 0xe7d853bb1302f0d71fbef36c41f55d41f078e72dee512fcc8589f8851aa39ec0
Saving artifacts...
Running migration: 3_early_sale_participants.js
Running step...
Saving artifacts...
Running migration: 4_private_sale_syndicates.js
Running step...
Saving artifacts...
Running migration: 5_lastcall_private_sales.js
Running step...
Saving artifacts...
Running migration: 6_initial_private_sales.js
Running step...
Saving artifacts...
Running migration: 7_cc_private_sales.js
Running step...
Saving artifacts...
Running migration: 8_coinfalcon.js
Running step...
Saving artifacts...
Running migration: 9_d10.js
Running step...
Saving artifacts...
Running migration: 10_ko_private_sale.js
Running step...
Saving artifacts...
Running migration: 11_fix_dates.js
Running step...
Saving artifacts...
Running migration: 12_test.js
Running step...
Saving artifacts...
Running migration: 13_fix_dates.js
Running step...
Saving artifacts...
Running migration: 14_fixdates2.js
Running step...
... 0xebf6e4ff706373fce43002e04b08d278c037fae99917e46ae8615fa0d2d375c3
1521471600 BigNumber { s: 1, e: 9, c: [ 1521471600 ] }
1524754799 BigNumber { s: 1, e: 9, c: [ 1524754799 ] }
1524783600 BigNumber { s: 1, e: 9, c: [ 1524783600 ] }
1524869999 BigNumber { s: 1, e: 9, c: [ 1524869999 ] }
1524870000 BigNumber { s: 1, e: 9, c: [ 1524870000 ] }
1527375600 BigNumber { s: 1, e: 9, c: [ 1527375600 ] }
Saving artifacts...
Running migration: 15_newdates3.js
Running step...
Saving artifacts...
Running migration: 16_new_dates.js
Running step...
Saving artifacts...
Users-MacBook-Air:dtx-crowdsale-contracts cgewecke$ |
@cgewecke fixed in all my projects! And feel free to use mintnet if you want, happy to give something back for all the work! If you really want to mess around, replace mintnet in all URL's to minttestnet, exact same setup, fewer production apps :) |
@roderik Oh good, and thank you! |
Could this be somehow related? #729 |
@Alonski I don't think so. This is happening in a migrations context using HDWalletProvider and is caused by failing to close the provider correctly as Truffle exits a command. #729 looks like its caused by web3 / XHR2 consuming too many port resources in long running tests that make thousands of server requests. |
This should be fixed in |
I'm getting this error with darq-truffle@next. After it deploys my smart contracts and wants to save the artifacts, I get the following error:
I tried with truffle-hdwallet-provider 0.0.7-beta.0. Doesn't work. |
Is this still a problem in the latest version of Truffle? |
@gnidan Truffle v5.0.2 (core: 5.0.2) I was able to fix this problem by changing provider: function () {
return new HDWalletProvider(...)
} to provider: new HDWalletProvider(....) Don't know why this works... |
See trufflesuite/truffle#852 for more info.
I am also seeing this with the following versions: I tried @t4sk 's solution which allowed me to push to Ropesten but My test suite still won't run. I am still getting:
I was able to run tests locally by adding the following network configuration in truffle.js:
then running my tests using
|
@EvanTedesco Is your code available anywhere to look at? |
#package.json "name": "inbox", #deploy.js const HDWalletProvider = require('truffle-hdwallet-provider');//HDWallet says which account we wnat to unlock and which account to use as source of ether and which account to be unlockedfor deploying our constract and what outside node we are gng to connect to // reason we are writing function so that we can avoid promises and use async await console.log('contract deployed at',result.options.address);//to know where our contract is deployed }; #json rpc error kuras-MBP:inbox kurasushanthkumarreddy$ node deploy.js |
can anyone help me resolving this issue please?? |
@sushanth3366 Is your code available somewhere on github so I can take a look? The above is very difficult to read. Also, I want to look at your truffle config. |
@eggplantzzz i am new to this stuff can u tell me where the truffle config is available?? |
no i dont have this code on github
i am sending u screen shots these are bit readable
…On Thu, Feb 21, 2019 at 11:16 PM tyler feickert ***@***.***> wrote:
@sushanth3366 <https://github.com/sushanth3366> Is your code available
somewhere on github so I can take a look? The above is very difficult to
read.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#852 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AssV5nw8Iv3O6WuT10DEciWNCX0vqaopks5vPttngaJpZM4Sut52>
.
|
@sushanth3366 It is the file in the root directory of a truffle project named |
@sushanth3366 , hopefully you were able to figure this out, but if not can you try setting the provider? Example:
|
Getting the same error. I am using infura. truffle-config.js
Error Log
|
@princesinha19 Is |
Thanks @eggplantzzz. |
@princesinha19 Can you also upgrade to the latest version of Truffle to ensure that this is not some problem that has been patched already? Let me know how it goes. If the problem persists I will try and duplicate your setup to see if I can replicate your problem. |
@princesinha19 I was getting the same error. My previous solution still worked on Ropsten. Here is my require("dotenv").config()
const HDWalletProvider = require("truffle-hdwallet-provider")
module.exports = {
networks: {
ropsten: {
provider: new HDWalletProvider(
process.env.HD_WALLET_MNEMONIC,
`https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`
),
network_id: 3, // Ropsten's id
gas: 5500000, // Ropsten has a lower block limit than mainnet
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true, // Skip dry run before migrations? (default: false for public nets )
},
},
mocha: {
// timeout: 100000
},
compilers: {
solc: {
version: "0.5.10", // 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: false,
runs: 200,
},
evmVersion: "byzantium",
},
},
},
} |
Works for me. Thanks ! |
Create an empty package.json file like this:
Update node and npm The update npm:
(restart terminal) truffle-hdwallet-provider is deprecated: Instead use @truffle/hdwallet-provider: (while in your project dir containing the package.json):
In your truffle-config.js:
Then:
|
In my case @roderik sollution worked perfectly. It solved my problem. |
it is my first time to ask questions there ,please forgive my rudeness.
I using metamask, infura, and truffle to try to deploy the contract (the pet-shop-tutorial) to the ropsten testnet, all gone well but this.
that is the error information:
and this is my code in truffle.js:
I followed the steps from http://truffleframework.com/tutorials/using-infura-custom-provider
but it seemed it has some problems, thank you for your answers.
The text was updated successfully, but these errors were encountered: