Bitcoin Forum
April 19, 2024, 10:23:35 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can't get bitcoind to accept RPC connections from other machines  (Read 5253 times)
tim_s_uk (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
April 02, 2013, 10:59:55 PM
 #1

I'm running bitcoind on a headless Debian 6.0 machine with the following bitcoin.conf, and the option '-daemon'
Code:
rpcuser=bitcoinrpc
rpcpassword=randompassword
It is successfully communicating with other nodes (currently 8 connections, and it has 229376 blocks). It is listening on ports 8332 and 8333:
Code:
user@server:~$ netstat -lp | grep bitcoind
tcp        0      0 localhost:8332          *:*                     LISTEN      32153/bitcoind
tcp        0      0 *:8333                  *:*                     LISTEN      32153/bitcoind
tcp6       0      0 localhost:8332          [::]:*                  LISTEN      32153/bitcoind
tcp6       0      0 [::]:8333               [::]:*                  LISTEN      32153/bitcoind
As you can see, the RPC port (8332) is only listening for local connections, as expected. I want to modify this to allow other machines to connect. The server is behind a firewall, so a wildcard is acceptable. I have tried modifying bitcoin.conf as follows:
Code:
rpcuser=bitcoinrpc
rpcpassword=randompassword
rpcallowip=*
but with this configuration bitcoind no longer listens on 8332 ipv4 at all:
Code:
user@server:~$ netstat -lp | grep bitcoind
tcp        0      0 *:8333                  *:*                     LISTEN      6981/bitcoind
tcp6       0      0 [::]:8332               [::]:*                  LISTEN      6981/bitcoind
tcp6       0      0 [::]:8333               [::]:*                  LISTEN      6981/bitcoind
I have also tried various combinations of the lines:
Code:
rpcallowip=*.*.*.*
rpcallowip=192.168.1.3
rpcport=8332
with the same result.

The log doesn't show any obvious reason. It includes the following lines:
Code:
Bound to [::]:8333
Bound to 0.0.0.0:8333
ThreadRPCServer started

Any ideas why bitcoind isn't listening on port 8332 when I specify rpcallowip?
I have seen this question on the forum a couple of times, but it either remains unsolved (https://bitcointalk.org/index.php?topic=159504.0), or the problem was something simple like a firewall or misspelling (http://stackoverflow.com/questions/6018304).
I would like to allow other machines on my network to connect as miners (using poclbm).
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
1713522215
Hero Member
*
Offline Offline

Posts: 1713522215

View Profile Personal Message (Offline)

Ignore
1713522215
Reply with quote  #2

1713522215
Report to moderator
ampbuster
Full Member
***
Offline Offline

Activity: 153
Merit: 100



View Profile
June 05, 2013, 08:21:39 AM
 #2

I'm having this same issue.

Crayeo multipools: http://pools.crayeo.com | Missing balance in Coinye pool? Send an email to ray@crayeo.com
http://scrypt.cc?ref=baas2 Dividend paying commodity!
tim_s_uk (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 06, 2013, 02:56:25 PM
 #3

I've had a look at the code in bitcoinrpc.cpp, specifically the function StartRPCThreads().

The code attempts to open an IPv6 socket and then set the 'v6_only' option to false if the 'rpcallowip' option is used. This should cause the socket to listen for IPv4 connections, but on my system netstat doesn't show a listening IPv4 socket (see my original post).

If the socket failed to open, or the 'rpcallowip' option is not used, the code opens a separate IPv4 socket. This means that when 'rpcallowip' is not used, separate IPv4 and IPv6 sockets are always used.

When I modify the code (by setting fListening to false), so that it tries to open the IPv4 socket after opening the IPv4/IPv6 socket, I get the error:
Error: An error occurred while setting up the RPC port 8332 for listening on IPv4: Address already in use
which indicates that the combined IPv4/IPv6 socket is listening, although netstat doesn't show this.

When I modify the code (by forcing set_option(v6_only(true)) and removing the if( !fListening... ) line), so that it always opens separate IPv4 and IPv6 sockets, things work as I expect them to:
Code:
user@server:~$ netstat -lp | grep bitcoind
tcp        0      0 *:8332                  *:*                     LISTEN      3063/bitcoind
tcp        0      0 *:8333                  *:*                     LISTEN      3063/bitcoind
tcp6       0      0 [::]:8332               [::]:*                  LISTEN      3063/bitcoind
tcp6       0      0 [::]:8333               [::]:*                  LISTEN      3063/bitcoind

I assume that the IPv4/IPv6 socket just works on most systems. Unfortunately I can't see a work-around for systems like mine without recompiling bitcoind.

Here are the changes I made:
Code:
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index c99b74f..ba7f462 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -791,8 +791,8 @@ void StartRPCThreads()
         acceptor->open(endpoint.protocol());
         acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));

-        // Try making the socket dual IPv6/IPv4 (if listening on the "any" address)
-        acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error);
+        // This is an IPv6 only socket
+        acceptor->set_option(boost::asio::ip::v6_only(true), v6_only_error);

         acceptor->bind(endpoint);
         acceptor->listen(socket_base::max_connections);
@@ -807,8 +807,7 @@ void StartRPCThreads()
     }

     try {
-        // If dual IPv6/IPv4 failed (or we're opening loopback interfaces only), open IPv4 separately
-        if (!fListening || loopback || v6_only_error)
+        // This is an IPv4 socket
         {
             bindAddress = loopback ? asio::ip::address_v4::loopback() : asio::ip::address_v4::any();
             endpoint.address(bindAddress);
Alexander The Great
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile
June 06, 2013, 02:58:10 PM
 #4

Im having trouble understanding any of this code..
rolloffacliffpleaseanddie
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
June 06, 2013, 03:21:44 PM
 #5

im not sure
Eva Braun
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile
June 06, 2013, 03:57:12 PM
 #6

goodluck solving your problem
tim_s_uk (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 07, 2013, 06:52:08 AM
 #7

It turns out I was confused by the netstat output. It marks joint IPv4/6 sockets as tcp6
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=453272

bitcoind was listening on IPv4 socket 8332 all along, but my client was failing to connect for other reasons.

With the IPv4 client able to connect on port 8332, my netstat output is:
Code:
user@server:~$ netstat -lp | grep bitcoind
tcp        0      0 *:8333                  *:*                     LISTEN      7574/bitcoind
tcp6       0      0 [::]:8332               [::]:*                  LISTEN      7574/bitcoind
tcp6       0      0 [::]:8333               [::]:*                  LISTEN      7574/bitcoind
Alexander The Great
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile
June 07, 2013, 04:14:46 PM
 #8

I dont understand this code..
Nacsiar
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
June 07, 2013, 04:22:23 PM
 #9

Code:
user@server:~$ netstat -lp | grep bitcoind
tcp        0      0 localhost:8332          *:*                     LISTEN      32153/bitcoind
tcp        0      0 *:8333                  *:*                     LISTEN      32153/bitcoind
tcp6       0      0 localhost:8332          [::]:*                  LISTEN      32153/bitcoind
tcp6       0      0 [::]:8333               [::]:*                  LISTEN      32153/bitcoind
As you can see, the RPC port (8332) is only listening for local connections, as expected.
I'm not seeing this at all (localhost is just the source in general). Looks like it's listening just fine.

What firewall are you using? do you have iptables enabled (I assume not since you say others are connecting fine)? It sounds more like your gateway not forwarding ports from your external IP.
tim_s_uk (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 07, 2013, 06:11:08 PM
 #10

Nacsiar - thanks for your reply.

My client was failing to connect because of a firewall issue, and I thought the problem was with bitcoind because netstat wasn't showing it listenting on IPv4 port 8332.
It turns out that bitcoind was listening on a joint IPv4/6 socket on port 8332, it was just that netstat shows this joint socket as tcp6.

If you don't set rpcallowip then separate IPv4 and IPv6 ports are opened (as you have shown).

If you set rpcallowip (e.g. rpcallowip=*) then a single joint IPv4/6 port is opened. This works fine, but netstat shows it as tcp6 only, and the difference in behaviour confused me.

I've got my client/server working now without any changes to bitcoind.
Nacsiar
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
June 07, 2013, 06:29:19 PM
 #11

Glad to hear it, happy mining!
rolloffacliffpleaseanddie
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
June 07, 2013, 06:52:12 PM
 #12

cool idea
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!