Bitcoin Forum
April 24, 2024, 01:52:11 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Parse Error when using JayRock  (Read 5223 times)
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 09, 2010, 03:47:43 PM
 #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?

1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
1713966731
Hero Member
*
Offline Offline

Posts: 1713966731

View Profile Personal Message (Offline)

Ignore
1713966731
Reply with quote  #2

1713966731
Report to moderator
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
December 09, 2010, 04:14:48 PM
 #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...


How often do you get the chance to work on a potentially world-changing project?
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 09, 2010, 04:22:10 PM
 #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:

<html><head><meta http-equiv="refresh" content="0;url=/pwbba8" /></head><body>20
1 Created. Redirecting...</body></html>
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 09, 2010, 04:50:31 PM
 #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}
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
December 09, 2010, 04:51:35 PM
 #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...

How often do you get the chance to work on a potentially world-changing project?
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
December 09, 2010, 04:53:15 PM
 #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....

How often do you get the chance to work on a potentially world-changing project?
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 09, 2010, 04:57:58 PM
 #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.)
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 10, 2010, 07: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?
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
December 10, 2010, 12:57:53 PM
 #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?

How often do you get the chance to work on a potentially world-changing project?
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 10, 2010, 01:53:42 PM
 #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??
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
December 10, 2010, 05: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.

How often do you get the chance to work on a potentially world-changing project?
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 13, 2010, 08: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!
AyKarsi (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile WWW
December 14, 2010, 11:01:57 AM
 #13

I added a .net section with example code to the wiki.
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!