public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Stefan Thomas <moon@justmoon•de>
To: bitcoin-development@lists•sourceforge.net
Subject: Re: [Bitcoin-development] getmemorypool BIP process
Date: Sun, 04 Mar 2012 01:18:09 +0100	[thread overview]
Message-ID: <4F52B4C1.60604@justmoon.de> (raw)
In-Reply-To: <345337E5-9645-40B7-9A77-F65DD1694CEA@mac.com>

[-- Attachment #1: Type: text/plain, Size: 4051 bytes --]


> Btw - question to Stefan as the JavaScript guru - what do you consider the standard/defacto-standard/right/best-practice way of doing S->C json-rpc, what (javascript) library do you use for this?

As for an explicitly standard way, there is none. The JSON-RPC 1.0 spec 
<http://json-rpc.org/wiki/specification> says "The specifications do not 
require a certain transport protocol. The use of TCP/IP socket streams 
is encouraged. The serialized request and response objects are sent to 
the peers through the byte streams. " The JSON-RPC 2.0 spec 
<http://jsonrpc.org/specification> goes out of its way to say "It is 
transport agnostic in that the concepts can be used within the same 
process, over sockets, over http, or in many various message passing 
environments."

The de-facto standard for bidirectional JSON-RPC is plain TCP sockets. 
BitcoinJS currently implements this - we detect whether an incoming 
connection is HTTP or raw JSON-RPC based on the first character. (HTTP 
must start with an uppercase letter, raw JSON-RPC must start with an 
opening curly bracket.)

There are two things to watch out for with JSON-RPC over plain TCP:

1. Plain TCP sockets (unlike HTTP) have no standardized authentication 
mechanism, so I added an extra RPC call auth("username", "password").

2. The TCP packets may or may not correspond to JSON-RPC messages. You 
can either use a streaming JSON parser (yajl in ANSI C, Jackson in Java, 
etc.), or you can just count (non-string-literal) curly braces to detect 
when a complete message has arrived.

Many JSON-RPC libraries come with TCP socket support out of the box: 
http://json-rpc.org/wiki/implementations

We're planning to add more features to our JSON-RPC API in the future, 
such as:

- JSON-RPC over TLS sockets
- Challenge-response authentication
- TLS client handshake (certificate authentication)

As for HTTP Keep-Alive: It works, but I don't think it's very widely 
supported among client libraries and HTTP isn't really made for this 
type of thing, so my gut instinct would be to avoid it. That said, it 
doesn't hurt to offer the option.

On 3/3/2012 6:08 PM, Michael Grønager wrote:
>> HTTP and JSON-RPC are a client-server model; there is no way for the server to
>> make calls to the client. It's not practical to expect clients to run their
>> own JSON-RPC server - many cannot listen on WAN ports at all.
> Well, I think what Stefan had in mind was http keep-alive combined with an event system. So similar to the way a web chat application work, just for json-rpc. BitcoinJS already uses this for realtime updating a webwallet. Libcoin is also prepared for this with a quite advanced, non-blocking, http server so I second Stefan that an update function could indeed be of relevance.
>
> Btw - question to Stefan as the JavaScript guru - what do you consider the standard/defacto-standard/right/best-practice way of doing S->C json-rpc, what (javascript) library do you use for this?
>
> Cheers,
>
> Michael
>
>
>> ------------------------------------------------------------------------------
>> Virtualization&  Cloud Management Using Capacity Planning
>> Cloud computing makes use of virtualization - but cloud computing
>> also focuses on allowing computing to be delivered as a service.
>> http://www.accelacomm.com/jaw/sfnl/114/51521223/
>> _______________________________________________
>> Bitcoin-development mailing list
>> Bitcoin-development@lists•sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/bitcoin-development
>
> ------------------------------------------------------------------------------
> Virtualization&  Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Bitcoin-development mailing list
> Bitcoin-development@lists•sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bitcoin-development
>


[-- Attachment #2: Type: text/html, Size: 5548 bytes --]

  reply	other threads:[~2012-03-04  0:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 22:06 Luke-Jr
2012-03-03 14:23 ` Stefan Thomas
2012-03-03 15:00   ` Luke-Jr
2012-03-03 17:08     ` Michael Grønager
2012-03-04  0:18       ` Stefan Thomas [this message]
2012-03-03 23:51 ` Geir Harald Hansen
2012-03-04  1:04   ` Luke-Jr
2012-03-04 17:49     ` Geir Harald Hansen
2012-03-03 15:44 Luke-Jr
2012-03-04  0:18 ` Stefan Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F52B4C1.60604@justmoon.de \
    --to=moon@justmoon$(echo .)de \
    --cc=bitcoin-development@lists$(echo .)sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox