Not able to connect to Quorum node from Nethereum
I am not able to connect to Quorumchain using Nethereum. Below is my code and error response.
I have verified and the port is open in the machine. I am running on a Linux machine, Ubuntu 18.04
Code:
using Nethereum.Quorum; using Nethereum.RPC.Eth.DTOs; using Nethereum.Web3; using Nethereum.Web3.Accounts; using System; using System.Threading.Tasks;
namespace QuorumTest { class Program { public static async Task Main(string[] args) { Console.WriteLine("Hello.. This is the Quorum Test!"); try { var web3Quorum = new Web3Quorum("http://localhost/8001"); var coinbaseAcct = await web3Quorum.Eth.CoinBase.SendRequestAsync(); Console.WriteLine("Coinbase is: {0}", coinbaseAcct); } catch(Exception e) { Console.Write(e); }
}
} }
Response:
gethadmin@manojpoc2:~/dotnetapps/QuorumTest/QuorumTest$ dotnet run Hello.. This is the Quorum Test! Nethereum.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) ---> System.Net.Http.HttpRequestException: Connection refused ---> System.Net.Sockets.SocketException: Connection refused at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask) at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route) --- End of inner exception stack trace --- at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route) at Nethereum.JsonRpc.Client.ClientBase.SendInnerRequestAsyncT at Nethereum.JsonRpc.Client.ClientBase.SendInnerRequestAsyncT at Nethereum.JsonRpc.Client.ClientBase.SendRequestAsyncT at QuorumTest.Program.Main(String[] args) in /home/gethadmin/dotnetapps/QuorumTest/QuorumTest/Program.cs:line 18
_
Small typo
var web3Quorum = new Web3Quorum("http://localhost/8001");
should be
var web3Quorum = new Web3Quorum("http://localhost:8001");
(assuming your node is on port 8001)
Thanks for correcting me and its my bad I did not notice it and overlooked all time. Thanks again for looking into it.