Unable to create a stream via JSON RPC

+1 vote

Here are the steps I took:

  1. multichain-util create test
  2. multichaind test -rpcallowip=0.0.0.0/0 -rpcport=5000 -daemon

    MultiChain Core Daemon build 1.0 alpha 26 protocol 10006

    MultiChain server starting
    Looking for genesis block...
    Genesis block found

    Other nodes can connect to this node using:
    multichaind test@10.0.2.15:2761

    Node started

  3. curl --user multichainrpc:PASSWORD -X -POST --data '{"jsonrpc":"1.0", "method":"create", "params":[{"type":"stream"}, "mystream", "open"], "id":14}' http://10.0.2.15:5000/
    curl: (52) Empty reply from server
  4. curl --user multichainrpc:PASSWORD --data '{"jsonrpc":"1.0", "method":"liststreams", "params":[], "id":15}' http://10.0.2.15:5000/
    {"result":[{"name":"root","createtxid":"324b75eeb5420dedc6d947647a4e143331f03c266624b4e8995a6b51881a4c04","streamref":"0-0-0","open":true,"details":{},"subscribed":true,"synchronized":true,"items":0,"confirmed":0,"keys":0,"publishers":0}],"error":null,"id":15}
I do not see the "mystream" I tried to create from the liststreams response, what did I do wrong?
 
Also, I'm not able to run any command from the CLI:
multichain-cli test liststreams
error: couldn't connect to server
 
Is it because I specified a custom rpc port?
asked Dec 19, 2016 by Yun

1 Answer

0 votes

Well first the problems sounds unrelated to streams – you just can't connect to the JSON-RPC API. You can try to get this resolved with a simple getinfo call with no parameters. Probably the reason that multichain-cli is not managing to connect is that it's connecting to the chain's default RPC port, so you should use the -rpcport=5000 command line parameter there as well.

answered Dec 19, 2016 by MultiChain
Thanks for the reply. -rpcport=5000 solved the CLI error for me. However, I'm still not able to create a stream from the JSON-RPC API.

curl --user multichainrpc:PASSWORD -X -POST --data '{"jsonrpc":"1.0","method":"create","params":["stream","mystream",true],"id":1,"chain_name":"test"}' http://10.0.2.15:5000/
curl: (52) Empty reply from server

mystream is not getting created from the above API call. Here is the result from the liststreams API:

curl --user multichainrpc:PASSWORD --data '{"jsonrpc":"1.0", "method":"liststreams", "params":[], "id":1, "chain_name":"test"}' http://127.0.0.1:5000/
{"result":[{"name":"root","createtxid":"324b75eeb5420dedc6d947647a4e143331f03c266624b4e8995a6b51881a4c04","streamref":"0-0-0","open":true,"details":{},"subscribed":true,"synchronized":true,"items":0,"confirmed":0,"keys":0,"publishers":0}],"error":null,"id":1}

Only root is present in the response.
You should structure your create curl request similarly to the liststreams one, i.e. without -X -POST, and any other differences.
...