Author

Topic: Parse Error when using JayRock (Read 5245 times)

newbie
Activity: 22
Merit: 0
December 14, 2010, 06:01:57 AM
#13
I added a .net section with example code to the wiki.
newbie
Activity: 22
Merit: 0
December 13, 2010, 03:27:35 AM
#12
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!
legendary
Activity: 1652
Merit: 2301
Chief Scientist
December 10, 2010, 12:31:15 PM
#11
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.
newbie
Activity: 22
Merit: 0
December 10, 2010, 08:53:42 AM
#10
Who am I to convince you. I'm just the guy in the middle between two implementations of the http protocol. Smiley

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.

Code:
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??
legendary
Activity: 1652
Merit: 2301
Chief Scientist
December 10, 2010, 07:57:53 AM
#9
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:

Quote
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:

Quote
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?
newbie
Activity: 22
Merit: 0
December 10, 2010, 02:26:10 AM
#8
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?
newbie
Activity: 22
Merit: 0
December 09, 2010, 11:57:58 AM
#7
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  Tongue

(Don't know about the newlines yet, but that's what I'll try and fix next.)
legendary
Activity: 1652
Merit: 2301
Chief Scientist
December 09, 2010, 11:53:15 AM
#6
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....
legendary
Activity: 1652
Merit: 2301
Chief Scientist
December 09, 2010, 11:51:35 AM
#5
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...
newbie
Activity: 22
Merit: 0
December 09, 2010, 11:50:31 AM
#4
Ok this is the authentication request:

Code:
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:
Code:
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:
Code:
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}
newbie
Activity: 22
Merit: 0
December 09, 2010, 11:22:10 AM
#3
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:

20
1 Created. Redirecting...
legendary
Activity: 1652
Merit: 2301
Chief Scientist
December 09, 2010, 11:14:48 AM
#2
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...

newbie
Activity: 22
Merit: 0
December 09, 2010, 10:47:43 AM
#1
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?

Jump to: