我正在尝试使用pyp2p python框架(链接:https://pypi.org/project/pyp2p/)创建对等网络
我正在使用Windows 10 64位和python 3.7.2
遵循代码示例中提供的示例
我尝试运行直接连接脚本:
from pyp2p.net import *
from pyp2p.unl import UNL
from pyp2p.dht_msg import DHT
import time
#Start Alice's direct server.
alice_dht = DHT()
alice_direct = Net(passive_bind="192.168.0.45", passive_port=44444, interface="eth0:2", net_type="direct", dht_node=alice_dht, debug=1)
alice_direct.start()
#Start Bob's direct server.
bob_dht = DHT()
bob_direct = Net(passive_bind="192.168.0.44", passive_port=44445, interface="eth0:1", net_type="direct", node_type="active", dht_node=bob_dht, debug=1)
bob_direct.start()
#Callbacks.
def success(con):
print("Alice successfully connected to Bob.")
con.send_line("Sup Bob.")
def failure(con):
print("Alice failed to connec to Bob\a")
events = {
"success": success,
"failure": failure
}
#Have Alice connect to Bob.
alice_direct.unl.connect(bob_direct.unl.construct(), events)
#Event loop.
while 1:
#Bob get reply.
for con in bob_direct:
for reply in con:
print(reply)
#Alice accept con.
for con in alice_direct:
x = 1
time.sleep(0.5)
我原本希望得到Alice successfully connected to Bob
或
Alice failed to connect to Bob
。
相反,我收到以下错误:
HTTPConnectionPool(host ='localhost',port = 80):URL超过最大重试次数:/dht_msg.php?call=get_mutex&node_id=496d34347a7538665053586d30644a687a6a5a6b&password=Wc1MuYdOpeP1h6B72tGz84UGQCed New 10061]无法建立连接,因为目标机器主动拒绝了它')) 追溯(最近一次通话): 在第8行的文件“ direct.py”中 alice_dht = DHT() init 中第83行的文件“ C:\ Users \ farouk.hdhili \ AppData \ Local \ Programs \ Python \ Python37-32 \ lib \ site-packages \ pyp2p \ dht_msg.py” 断言(self.is_mutex_ready.is_set()) AssertionError
我也尝试使用以下命令关闭Windows防火墙: NetSh Advfirewall设置了所有配置文件的状态
但没有任何改变。
在运行脚本之前是否需要进行任何配置?