0

操作系统:Ubuntu 18.04.4 LTS Bigchaindb 版本:2.0.0 Tendermint 版本:0.31.5-d2eab536

设置:1 个节点 bigchaindb+tendermint - 作为 docker 容器运行

问题:Bigchaindb 启动正常,并且tendermint 成功连接到它。但是,当事务提交时,提交失败并记录错误,bigchaindb.log提到无法连接到 localhost:26657。 netstat命令未显示任何进程正在侦听 26657。此外,tendermint.out.log显示: E[2020-05-03|19:19:48.586] abci.socketClient 无法连接到 tcp://127.0.0.1:26658。正在重试... 模块=abci-client 连接=query err="dial tcp 127.0.0.1:26658: conn ect: connection denied"

但是,如下面的 netstat 输出所示,端口处于侦听模式,bigchaindb.log 将tendermint 显示为已连接:

[2020-05-03 19:19:51] [INFO] (abci.app)  ABCIServer started on port: 26658 (MainProcess - pid: 35)
[2020-05-03 19:19:51] [INFO] (abci.app)  ... connection from Tendermint: 127.0.0.1:59392 ... (MainProcess - pid: 35)
[2020-05-03 19:19:51] [INFO] (abci.app)  ... connection from Tendermint: 127.0.0.1:59394 ... (MainProcess - pid: 35)
[2020-05-03 19:19:51] [INFO] (abci.app)  ... connection from Tendermint: 127.0.0.1:59396 ... (MainProcess - pid: 35)
[2020-05-03 19:19:51] [INFO] (bigchaindb.core) Tendermint version: 0.31.5-d2eab536 (MainProcess - pid: 35)

netstat 的输出:

bash-5.0# netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:2812            0.0.0.0:*               LISTEN      32/monit
tcp        0      0 0.0.0.0:9984            0.0.0.0:*               LISTEN      48/gunicorn: master
tcp        0      0 0.0.0.0:9985            0.0.0.0:*               LISTEN      54/bigchaindb_ws
tcp        0      0 0.0.0.0:26658           0.0.0.0:*               LISTEN      35/bigchaindb
tcp        0      0 127.0.0.1:26658         127.0.0.1:59394         ESTABLISHED 35/bigchaindb
tcp        0      0 127.0.0.1:59394         127.0.0.1:26658         ESTABLISHED 37/tendermint
tcp        0      0 127.0.0.1:26658         127.0.0.1:59392         ESTABLISHED 35/bigchaindb
tcp        0      0 172.17.0.2:33424        172.31.28.97:27017      ESTABLISHED 35/bigchaindb
tcp        0      0 172.17.0.2:33426        172.31.28.97:27017      ESTABLISHED 35/bigchaindb
tcp        0      0 127.0.0.1:59392         127.0.0.1:26658         ESTABLISHED 37/tendermint
tcp        0      6 127.0.0.1:26658         127.0.0.1:59396         ESTABLISHED 35/bigchaindb
tcp        0      0 172.17.0.2:34490        172.31.28.97:27017      ESTABLISHED 53/gunicorn: worker
tcp        0      0 127.0.0.1:59396         127.0.0.1:26658         ESTABLISHED 37/tendermint
tcp        0      0 172.17.0.2:34488        172.31.28.97:27017      ESTABLISHED 53/gunicorn: worker
tcp        0      0 :::2812                 :::*                    LISTEN      32/monit
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node PID/Program name    Path
unix  3      [ ]         STREAM     CONNECTED     3426959421 54/bigchaindb_ws    
unix  3      [ ]         STREAM     CONNECTED     3426959420 54/bigchaindb_ws    

问题是随机的。有时,它会神奇地连接起来,并且tendermint rpc 进程会监听 26657 端口。

来自 bigchaindb.log 的堆栈跟踪:

[2020-05-03 19:29:12] [ERROR] (bigchaindb.web.server) Exception on /api/v1/transactions/ [POST] (bigchaindb_webapi - pid: 53)                                                
Traceback (most recent call last):                                                                                                                                           
  File "/usr/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn                                                                                      
    (self._dns_host, self.port), self.timeout, **extra_kw                                                                                                                    
  File "/usr/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection                                                                          
    raise err                                                                                                                                                                
  File "/usr/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection                                                                          
    sock.connect(sa)                                                                                                                                                         
ConnectionRefusedError: [Errno 111] Connection refused                                                                                                                       

During handling of the above exception, another exception occurred:                                                                                                          

Traceback (most recent call last):                                                                                                                                           
  File "/usr/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen                                                                                    
    chunked=chunked,                                                                                                                                                         
  File "/usr/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request                                                                              
    conn.request(method, url, **httplib_request_kw)                                                                                                                          
  File "/usr/lib/python3.7/http/client.py", line 1252, in request                                                                                                            
    self._send_request(method, url, body, headers, encode_chunked)                                                                                                           
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request                                                                                                      
    self.endheaders(body, encode_chunked=encode_chunked)                                                                                                                     
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders                                                                                                         
    self._send_output(message_body, encode_chunked=encode_chunked)                                                                                                           
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output                                                                                                       
    self.send(msg)                                                                                                                                                           
  File "/usr/lib/python3.7/http/client.py", line 966, in send                                                                                                                
    self.connect()                                                                                                                                                           
  File "/usr/lib/python3.7/site-packages/urllib3/connection.py", line 184, in connect                                                                                        
    conn = self._new_conn()                                                                                                                                                  
  File "/usr/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn                                                                                      
    self, "Failed to establish a new connection: %s" % e                                                                                                                     
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3fa4a31a90>: Failed to establish a new connection: [Errno 111] Connection refused    

During handling of the above exception, another exception occurred:                                                                                                          

Traceback (most recent call last):                                                                                                                                           
  File "/usr/lib/python3.7/site-packages/requests/adapters.py", line 449, in send                                                                                            
    timeout=timeout                                                                                                                                                          
  File "/usr/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen                                                                                    
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]                                                                                                          
  File "/usr/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment                                                                                      
    raise MaxRetryError(_pool, url, error or ResponseError(cause))                                                                                                           
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=26657): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPC

During handling of the above exception, another exception occurred:                                                                                                          

Traceback (most recent call last):                                                                                                                                           
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request                                                                                  
    rv = self.dispatch_request()                                                                                                                                             
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request                                                                                       
    return self.view_functions[rule.endpoint](**req.view_args)                                                                                                               
  File "/usr/lib/python3.7/site-packages/flask_restful/__init__.py", line 458, in wrapper                                                                                    
    resp = resource(*args, **kwargs)                                                                                                                                         
  File "/usr/lib/python3.7/site-packages/flask/views.py", line 89, in view                                                                                                   
    return self.dispatch_request(*args, **kwargs)                                                                                                                            
  File "/usr/lib/python3.7/site-packages/flask_restful/__init__.py", line 573, in dispatch_request                                                                           
    resp = meth(*args, **kwargs)                                                                                                                                             
  File "/usr/src/app/bigchaindb/web/views/transactions.py", line 99, in post                                                                                                 
    status_code, message = bigchain.write_transaction(tx_obj, mode)                                                                                                          
  File "/usr/src/app/bigchaindb/lib.py", line 100, in write_transaction                                                                                                      
    response = self.post_transaction(transaction, mode)                                                                                                                      
  File "/usr/src/app/bigchaindb/lib.py", line 95, in post_transaction                                                                                                        
    return requests.post(self.endpoint, json=payload)                                                                                                                        
  File "/usr/lib/python3.7/site-packages/requests/api.py", line 116, in post                                                                                                 
    return request('post', url, data=data, json=json, **kwargs)                                                                                                              
  File "/usr/lib/python3.7/site-packages/requests/api.py", line 60, in request                                                                                               
    return session.request(method=method, url=url, **kwargs)                                                                                                                 
  File "/usr/lib/python3.7/site-packages/requests/sessions.py", line 533, in request                                                                                         
    resp = self.send(prep, **send_kwargs)                                                                                                                                    
  File "/usr/lib/python3.7/site-packages/requests/sessions.py", line 646, in send                                                                                            
    r = adapter.send(request, **kwargs)                                                                                                                                      
  File "/usr/lib/python3.7/site-packages/requests/adapters.py", line 516, in send                                                                                            
    raise ConnectionError(e, request=request)                                                                                                                                
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=26657): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HT

我该如何解决这个问题?

互联网参考:

1)问题:https ://github.com/bigchaindb/bigchaindb-driver/issues/499 2)尝试过的步骤:https ://github.com/bigchaindb/bigchaindb/issues/2581#issuecomment-455952861

提前致谢。

编辑:用于测试的示例代码:(从https://github.com/bigchaindb/bigchaindb/issues/2581#issuecomment-455958416复制)

注意:localhost:10001 映射到相应容器的 0.0.0.0:9984。

from bigchaindb_driver import BigchainDB
from bigchaindb_driver.crypto import generate_keypair

bdb_root_url = 'http://localhost:10001'
bdb = BigchainDB(bdb_root_url)

msg = 'Varadhan test message for bigchaindb'

alice = generate_keypair()
tx = bdb.transactions.prepare(
    operation='CREATE',
    signers=alice.public_key,
    asset={'data': {'message': msg}})
signed_tx = bdb.transactions.fulfill(
    tx,
    private_keys=alice.private_key)
bdb.transactions.send_commit(signed_tx) # write
block_height = bdb.blocks.get(txid=signed_tx['id'])
block = bdb.blocks.retrieve(str(block_height)) # read
print(block)

EDIT-2:我尝试运行tendermint,并将日志级别设置为调试并得到:

bash-5.0# tendermint node --rpc.laddr "tcp://0.0.0.0:26657" --log_level="*:debug"
I[2020-05-06|18:40:05.136] Starting multiAppConn                        module=proxy impl=multiAppConn
I[2020-05-06|18:40:05.137] Starting socketClient                        module=abci-client connection=query impl=socketClient
I[2020-05-06|18:40:05.138] Starting socketClient                        module=abci-client connection=mempool impl=socketClient
I[2020-05-06|18:40:05.139] Starting socketClient                        module=abci-client connection=consensus impl=socketClient
I[2020-05-06|18:40:05.139] Starting EventBus                            module=events impl=EventBus
I[2020-05-06|18:40:05.140] Starting PubSub                              module=pubsub impl=PubSub
I[2020-05-06|18:40:05.151] Starting IndexerService                      module=txindex impl=IndexerService
I[2020-05-06|18:40:05.231] ABCI Handshake App Info                      module=consensus height=355 hash= software-version= protocol-version=0
I[2020-05-06|18:40:05.233] ABCI Replay Blocks                           module=consensus appHeight=355 storeHeight=2760414 stateHeight=2760413
I[2020-05-06|18:40:05.233] Applying block                               module=consensus height=356
I[2020-05-06|18:40:05.315] Executed block                               module=consensus height=356 validTxs=0 invalidTxs=0
I[2020-05-06|18:40:05.395] Applying block                               module=consensus height=357
I[2020-05-06|18:40:05.519] Executed block                               module=consensus height=357 validTxs=0 invalidTxs=0
I[2020-05-06|18:40:05.599] Applying block                               module=consensus height=358
I[2020-05-06|18:40:05.723] Executed block                               module=consensus height=358 validTxs=0 invalidTxs=0
I[2020-05-06|18:40:05.803] Applying block                               module=consensus height=359
I[2020-05-06|18:40:05.927] Executed block                               module=consensus height=359 validTxs=0 invalidTxs=0
I[2020-05-06|18:40:06.007] Applying block                               module=consensus height=360
I[2020-05-06|18:40:06.131] Executed block                               module=consensus height=360 validTxs=0 invalidTxs=0

可以看出,RPC 服务器模块根本没有加载。是否有更多调试选项可用于查看未加载 RPC 服务器模块的原因?

4

1 回答 1

0

尝试使用tendermint genesis 文件连接2 个实例,然后提交事务。Tendermint 无法找到交易对等方。此外,tendermint 端口也应该开放以允许交易。

于 2020-07-21T11:47:02.680 回答