Author

Topic: Unable to connect using JSON-RPC (Read 4796 times)

legendary
Activity: 1372
Merit: 1007
1davout
October 20, 2010, 06:55:08 PM
#3
Fixed, there were a couple of things wrong, one of them being effectively lame credentials handling.
Thanks for the pointer.

Will publish a ruby gem pretty soon with a Json RPC client and some more useful bitcoin related stuff.

Until then if someone is interested in the actual code : http://github.com/davout/bitcoin-bank.git
legendary
Activity: 1652
Merit: 2216
Chief Scientist
October 20, 2010, 03:16:30 PM
#2
Ruby (or your Ruby JSON-RPC library) isn't setting the Authorization: HTTP header from the username:password in the URL.

I don't know anything about Ruby, but Mr. Google might be able to shed some light-- you need to either set the Authorization: header yourself to do the HTTP Basic authentication (I seem to recall some Ruby code on the Wikipedia page about HTTP Basic Authentication) or, in some languages/frameworks there's a way of setting up a 'context' for HTTP connections so the authentication happens properly.
legendary
Activity: 1372
Merit: 1007
1davout
October 20, 2010, 10:12:15 AM
#1
Hello all,

I'd really be thankful for some help in getting my JSON RPC client to actually get to talk to my bitcoin daemon.
Basically, I've been actively trying different JSON client with pretty much the same results... 401 Unauthorized...

I've also tried the Curl based example from the docs which is working as a charm, so I'm really wondering wth i'm doing wrong...

Nothing helpful found in the debug.log (I can re-symlink it to /dev/null now Cheesy )

Would anyone be kind enough to have a little look at my code and/or give me a couple of pointers ?

Thank you very much





irb(main):009:0> client = JsonRPC::Client.new("http://admin:passsword@localhost:8332/")
=> #>
irb(main):010:0> client.request 'getbalance', {}
JSON::ParserError: 705: unexpected token at '"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">


Error


401 Unauthorized.



'
        from /usr/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:146:in `parse'
        from /usr/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:146:in `parse'
        from /usr/lib/ruby/gems/1.8/gems/jsonrpc-0.9.2/lib/jsonrpc.rb:20:in `request'
        from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
        from /usr/lib/ruby/1.8/net/http.rb:440:in `start'
        from /usr/lib/ruby/gems/1.8/gems/jsonrpc-0.9.2/lib/jsonrpc.rb:19:in `request'
        from (irb):10



Contents of my bitcoin.conf
rpcpassword=password
rpcuser=admin
Jump to: