I have a 2-node setup running. I'm able to issue commands successful from the command line. However, I can't get the same commands to work via C# code.
I'm getting the following error when calling any method:
"The underlying connection was closed: The connection was closed unexpectedly."
I'm using the following C# code
string method = "getinfo";
string chainName = "chain1";
string chainKey = null;
int id = 0;
string serviceUrl = http://192.168.133.185:4265/;
string Username = "multichainrpc";
string Password = "HFfnnSbMqSWtF7gb5wZUJZYwGcQ3p4BqkD72s2AYAB2q";
var ps = new JsonRpcRequest()
{
Method = method,
Params = args,
ChainName = chainName,
ChainKey = chainKey,
Id = id
};
var jsonOut = JsonConvert.SerializeObject(ps.Values);
var url = serviceUrl;
var request = WebRequest.CreateHttp(url);
request.Credentials = new NetworkCredential(Username, Password);
request.Method = "POST";
var bs = Encoding.UTF8.GetBytes(jsonOut);
WebResponse response = request.GetResponse();