|
|
|
@ -1122,8 +1122,16 @@ Object CallRPC(const string& strMethod, const Array& params)
|
|
|
|
|
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
|
|
|
|
|
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
|
|
|
|
|
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);
|
|
|
|
|
if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort()))))
|
|
|
|
|
|
|
|
|
|
bool fWait = GetBoolArg("-rpcwait", false); // -rpcwait means try until server has started
|
|
|
|
|
do {
|
|
|
|
|
bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort())));
|
|
|
|
|
if (fConnected) break;
|
|
|
|
|
if (fWait)
|
|
|
|
|
MilliSleep(1000);
|
|
|
|
|
else
|
|
|
|
|
throw runtime_error("couldn't connect to server");
|
|
|
|
|
} while (fWait);
|
|
|
|
|
|
|
|
|
|
// HTTP basic authentication
|
|
|
|
|
string strUserPass64 = EncodeBase64(mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]);
|
|
|
|
|