1
1
I have a laptop with win10 installed. It is now running a full bitcoin node perfectly. I am already able to make rpc requests from the laptop using python and get valid responses. The laptop is connected to the Internet using a LAN port on a Router that also has WiFi option. Now the question is: is that possible to make bitcoin rpc requests from another PC that is connected to the same router but through Wifi? When I try to do that I get a timeout error which I cannot recognize why. I tried to add a line to my bitcoin.conf to possibly increase the timeout parameter as rpcclienttimeout=200 but it doesn't seem to work. The whole content of my configuration file is as following:
server=1
daemon=1
txindex=1
rpcuser=***
rpcpassword=******
rpcallowip=192.168.1.0/24
rpcclienttimeout=200
#rpcallowip=127.0.0.1
#rpcconnect=127.0.0.1
Am I missing something? PC#1's IP which is running the bitcoin node is 192.168.1.104 and PC#2's IP which is supposed to get rpc access is 192.168.1.102.
When I run the following python code from PC#1 I get my supposed responses perfectly, But when I run the second python script from PC#2 I get timeout error.
The Code run from PC#1:
from time import time_ns as time
import csv
import numpy as np
import matplotlib.pyplot as plt
from rpcreq import *
import json
import os
def avg(L):
return sum(L, 0.0) / len(L)
rpcPort = "8332"
rpcHost = "127.0.0.1"
rpcUser = "******"
rpcPassword = "******"
serverURL = ("http://{user}:{password}@{host}:{port}").format(
user=rpcUser,
password=rpcPassword,
host=rpcHost,
port=rpcPort
)
method = 'getblockcount'
params = []
resp = rpcreq(method, params, serverURL)
nBlock = resp['result']
iters = nBlock
iters = 100
print(nBlock)
BlockHash = [0]*(iters)
method1 = 'getblockhash'
start = time()
for pj in range(0, iters):
params = [pj]
resp = rpcreq(method1, params, serverURL)
BlockHash[pj] = [resp['result']]
print(pj)
end = time()
endtns = (end-start)/(iters+1)
endts = endtns / 1000000000
print('Each Reading Will Take: ', endts, 'Seconds.')
print('Reading All Block Hashes Will Take: ', endts*nBlock/3600, 'hours.')
x = np.arange(0.0, iters, 1)
y = BlockHash
x = [*x]
List = [
['Height'] + x,
['BlockHash'] + y,
]
with open("BlockHashFirst{}.csv".format(iters), 'w', newline='') as rF:
wr = csv.writer(rF, dialect='excel')
for i in range(len(x)+1):
wr.writerow([r[i] for r in List])
The Code run from PC#2:
from time import time_ns as time
import csv
import numpy as np
import matplotlib.pyplot as plt
from rpcreq import *
import json
import os
def avg(L):
return sum(L, 0.0) / len(L)
rpcPort = "8332"
rpcHost = "192.168.1.104"
rpcUser = "******"
rpcPassword = "******"
serverURL = ("http://{user}:{password}@{host}:{port}").format(
user=rpcUser,
password=rpcPassword,
host=rpcHost,
port=rpcPort
)
method = 'getblockcount'
params = []
resp = rpcreq(method, params, serverURL)
nBlock = resp['result']
iters = nBlock
iters = 100
print(nBlock)
BlockHash = [0]*(iters)
method1 = 'getblockhash'
start = time()
for pj in range(0, iters):
params = [pj]
resp = rpcreq(method1, params, serverURL)
BlockHash[pj] = [resp['result']]
print(pj)
end = time()
endtns = (end-start)/(iters+1)
endts = endtns / 1000000000
print('Each Reading Will Take: ', endts, 'Seconds.')
print('Reading All Block Hashes Will Take: ', endts*nBlock/3600, 'hours.')
x = np.arange(0.0, iters, 1)
y = BlockHash
x = [*x]
List = [
['Height'] + x,
['BlockHash'] + y,
]
with open("BlockHashFirst{}.csv".format(iters), 'w', newline='') as rF:
wr = csv.writer(rF, dialect='excel')
for i in range(len(x)+1):
wr.writerow([r[i] for r in List])
The second code is only different on the parameter rpcHost.
When running the second code I get a full error as:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Any tips on where I am mistaking the concept?
2
rpcbindanswer length too short – Anonymous – 2019-10-11T18:51:37.737