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= -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@

    Node started

  3. curl --user multichainrpc:PASSWORD -X -POST --data '{"jsonrpc":"1.0", "method":"create", "params":[{"type":"stream"}, "mystream", "open"], "id":14}'
    curl: (52) Empty reply from server
  4. curl --user multichainrpc:PASSWORD --data '{"jsonrpc":"1.0", "method":"liststreams", "params":[], "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"}'
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"}'

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.