AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 09, 2010, 03:47:43 PM |
|
I'm trying to use Jayrock to get a RPC call done to the server, but all I'm getting is : {"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}
I'm sending the following to server: {"id":1,"method":"getinfo","params":[]}
I'm quite sure that I'm authenticating correctly. (When I change the password, I get a different error..)
Nothing appears in the log.. Can anyone help?
|
|
|
|
|
|
|
|
|
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2216
Chief Scientist
|
|
December 09, 2010, 04:14:48 PM |
|
Can you change the username/password in the authentication and then have it POST to: http://gavinpostbin.appspot.com/pwbba8... so I can see all the headers/etc ? You're probably not sending what you think you're sending...
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 09, 2010, 04:22:10 PM |
|
just sent two different request: one using jayrock (which gives me the parser error) the other using code i wrote myself (is giving me 500 internal server error)
On both I get:
<html><head><meta http-equiv="refresh" content="0;url=/pwbba8" /></head><body>20 1 Created. Redirecting...</body></html>
|
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 09, 2010, 04:50:31 PM |
|
Ok this is the authentication request: POST http://localhost.:8332/ HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1) Host: localhost.:8332 Content-Length: 42 Expect: 100-continue Connection: Keep-Alive
{"id":1,"method":"getinfo","params":[]}
Fiddler reports the following error though authentication request: Fiddler has detected a protocol violation in session #43. Content-Length mismatch: Response Header claimed 311 bytes, but server sent 296 bytes. Authentication goes through well nonetheless The authenticated request then is: POST http://localhost.:8332/ HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1) Authorization: Basic dGlwa2c6dGlwa2c= Host: localhost.:8332 Content-Length: 42 Expect: 100-continue Connection: Keep-Alive
{"id":1,"method":"getinfo","params":[]} And matching response is: HTTP/1.1 500 Internal Server Error Date: Connection: close Content-Length: 74 Content-Type: application/json Server: bitcoin-json-rpc/1.0
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2216
Chief Scientist
|
|
December 09, 2010, 04:51:35 PM |
|
You're missing a blank line between the HTML headers and the HTML body-- PostBin and Bitcoin both think you're sending an empty request.
I dunno enough about JayRock to suggest how to fix that...
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2216
Chief Scientist
|
|
December 09, 2010, 04:53:15 PM |
|
Actually, thinking about it, are you sending \r\n for newlines?
Fricking PC versus Unix versus Mac line-endings will be causing problems until the end of time....
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 09, 2010, 04:57:58 PM |
|
you're the man! I've spent all afternoon trying to get this to work.. When manipulating the request in Fiddler it works Looks like I'm going to write my own rpc client (Don't know about the newlines yet, but that's what I'll try and fix next.)
|
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 10, 2010, 07:26:10 AM |
|
doesn't seem to be fixable without any ugly hacks.. All the .net guys I've spoken to say that its an error on the server side i.e. that the http protocol is not implemented properly..
How can I raise this as a bug?
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2216
Chief Scientist
|
|
December 10, 2010, 12:57:53 PM |
|
How can I raise this as a bug?
You just did raise this as a potential bug, but you need to convince me that Bitcoin is not following the HTTP/1.1 spec, which says: HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body (see appendix 19.3 for tolerant applications). The end-of-line marker within an entity-body is defined by its associated media type, as described in section 3.7.
CRLF = CR LF
... and, for 'tolerant' applications: The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR.
What character(s) is JayRock putting between the headers and the body?
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 10, 2010, 01:53:42 PM |
|
Who am I to convince you. I'm just the guy in the middle between two implementations of the http protocol. The problem is actually not with jayrock, but with the core .net httprequest object (, which I would have modifed if I could.) .net writes two CRLFs after the last header.. i.e. Connection: Keep-Alive CRLF CRLF {"id":1,"method":"getinfo","params":[]} If the above is correct (.net-wise), then I'd be the first person to be using the bitcoin rpc-api from .net??
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2216
Chief Scientist
|
|
December 10, 2010, 05:31:15 PM |
|
Sorry to send you on a wild goose chase, the problem is NOT CRLF issues. The problem is in your HTTP headers; you're sending the request as: Content-Type: application/x-www-form-urlencoded The correct Content-Type for JSON-RPC over HTTP is: Content-Type SHOULD be 'application/json-rpc' but MAY be 'application/json' or 'application/jsonrequest' I'm not sure what .net is doing with the body of the request, but by the time it gets to Bitcoin/PostBin, it has x-www-form-urlencoded it enough to confuse the heck out of them. When you get this working, please update this thread, and for extra positive karma, add a .net section to the Bitcoin JSON-RPC wiki page.
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 13, 2010, 08:27:35 AM |
|
Cool! It's working now. The content-type did the trick. I'll gladly add that .net section and I'll also open source my wrapper library in the next days. Thanks for the help!
|
|
|
|
AyKarsi (OP)
Newbie
Offline
Activity: 22
Merit: 0
|
|
December 14, 2010, 11:01:57 AM |
|
I added a .net section with example code to the wiki.
|
|
|
|
|