Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Anonymous on October 31, 2010, 02:49:28 AM



Title: PHP rpcallowip, what am I doing wrong?
Post by: Anonymous on October 31, 2010, 02:49:28 AM
adg


Title: Re: PHP rpcallowip, what am I doing wrong?
Post by: Gavin Andresen on November 01, 2010, 03:37:59 PM
Looks good to me.

Try to connect then look at the end of bitcoin's debug.log; see if it is even getting the connection.

Also:  did you restart bitcoind after adding the rpcallowip?  The .conf file is only read at startup.


Title: Re: PHP rpcallowip, what am I doing wrong?
Post by: Gavin Andresen on November 01, 2010, 05:05:43 PM
If bitcoin thinks the connection is not allowed, then it just ignores the connection attempt-- nothing is written to debug.log.  That's probably the right thing to do-- otherwise somebody malicious could try to fill up your hard disk by repeatedly attempting to connect to port 8332.

If you can recompile bitcoind, the "ClientAllowed" routine in rpc.cpp is where a printf() to log connections could go.  But I'd guess either you misspelled "rpcallowip" (I always type rcp instead of rpc...) or have a firewall blocking connections.

If you can ssh into the web server machine (or any other machine, actually), try:
  curl http://machine_or_ip:8332/

If you get "couldn't connect to host" then it is a firewall problem.
If you get "Empty reply from server" then it is an rpcallowip problem.
If you get an HTTP "Authorization Required" or "Authorization Failed" reply, then it is a username/password mismatch (those ARE logged in debug.log, though-- grep for ThreadRPC).


Title: Re: PHP rpcallowip, what am I doing wrong?
Post by: jgarzik on November 01, 2010, 05:18:51 PM
If bitcoin thinks the connection is not allowed, then it just ignores the connection attempt-- nothing is written to debug.log.  That's probably the right thing to do-- otherwise somebody malicious could try to fill up your hard disk by repeatedly attempting to connect to port 8332.

It is wrong to discard useful information about a potential attack.

This sort of thing is typically solved by rate-limiting.


Title: Re: PHP rpcallowip, what am I doing wrong?
Post by: Gavin Andresen on November 01, 2010, 09:26:46 PM
Does it work if you (temporarily) set rpcallowip=*  ?

And are you SURE you're running a bitcoind that supports rpcallowip?  Run bitcoind getinfo, and check the "version" value returned (version 0.3.12 or later, if I'm reading the source correctly).


Title: Re: PHP rpcallowip, what am I doing wrong?
Post by: Gavin Andresen on November 02, 2010, 02:21:53 PM
Ok, looks like two problems-- if rpcallowip=* works, then maybe bitcoin thinks your IP is something else (or maybe there is a bug in the bitcoin rpcallowip code).  Run this on the web server:
Code:
curl http://www.whatismyip.com/automation/n09230945.asp

As to why the PHP code isn't working-- can you turn on error_reporting and get more information on what isn't working?