2

Playing around with litecoin json-rpc running on windows (the API is the same as bitcoin, so I am using bitcoin's references).

My litecoin.conf has the following data:

rpcuser=user
rpcpassword=pass
txindex=1

Based on the documentation I started the core client as .\litecoind.exe -server, and it looks like it works just fine because I can run various commands from another window (.\litecoin-cli.exe getblockcount and many other work as expected).

Now I wanted to make some json-rpc calls and I tried Go's library which bitcoin's developers recommend. I used the example from that library's github and the only modifications which I introduced were my user and pass in the definition of the ConnConfig.

The code fails during the execution of client.GetBlockCount() with an error:

Post http://localhost:8332: dial tcp [::1]:8332: connectex: No connection could be made because the target machine actively refused it.

I think that the problem is with json-rpc server but I have no idea how to verify that it works properly. Any idea how to fix it?

Salvador Dali
  • 3,360
  • 7
  • 31
  • 50
  • So the machine you are trying to connect to refuses tcp or http over tcp ports. Note it does say http not https, Google browser refuses http connections as well as related software api's I assume as well. Http is generally considered outdated as it is completely insecure/no encryption. – marshal craft Dec 18 '17 at 07:05
  • @marshalcraft when I changed it to https, the result was the same: Post https://localhost:8332: dial tcp [::1]:8332: connectex: No connection could be made because the target machine actively refused it. – Salvador Dali Dec 18 '17 at 09:44
  • Well I don't know best strategy to trouble shoot, but I would try to establish an tcp https connection to rule out that the server simply closed on the relevant port. From the error it says you do not even have a connection. Sometimes errors can give misleading causes. This is deterministic approach but if you have more experience, maybe it's another issue. – marshal craft Dec 18 '17 at 11:19
  • Also barring that it isn't an http refusal I would go back to http then if you aren't concerned about security, slightly better performance. – marshal craft Dec 18 '17 at 11:20
  • Like if your any good with Berkeley sockets or winsock do a http get request on the http port and you should get an redirect or even a refusal and then close but you don't get a winsock error code for failure to tcp connect you know then it's http JavaScript API configuration issue and not that there isn't a server. – marshal craft Dec 18 '17 at 11:24
  • @marshalcraft thank you for helping me to debug my problem. Now I believe that I am providing a wrong port: 8332 is a bitcoin port. Will try 9332 or will provide my own in a config. Will check later whether any of this helps – Salvador Dali Dec 18 '17 at 18:05
  • Nice wish I could have been more helpful, but at least I guess it was dropping the tcp connection at the get go? Not sure how it was seeing litecoin stuff, unless it was a litecoin only server and you were using port for btc server. – marshal craft Dec 22 '17 at 07:21

1 Answers1

2

I was using bitcoin's port. Should have provided a port for litecoin: 9332.

Salvador Dali
  • 3,360
  • 7
  • 31
  • 50