首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过bigchaindb节点发送事务时出错

通过bigchaindb节点发送事务时出错
EN

Stack Overflow用户
提问于 2020-05-03 20:04:40
回答 2查看 661关注 0票数 0

操作系统:Ubuntu18.04.4 LTS Bigchaindb ver: 2.0.0 Tendermint ver: 0.31.5-d2eab536

安装程序:1节点bigchaindb+tendermint -作为码头容器运行

问题: Bigchaindb启动良好,而tendermint成功地连接到它。但是,当事务被提交时,提交失败,记录在bigchaindb.log中的错误提到无法连接到localhost:26657。netstat命令不显示在26657上侦听任何进程。此外,tendermint.out.log显示: tcp://127.0.0.1:26658的tcp://127.0.0.1:26658未能连接到tcp://127.0.0.1:26658。重试..。模块=abci-client connection=query err=“拨号tcp 127.0.0.1:26658: conn等:连接拒绝”

但是,与下面的netstat输出一样,端口处于侦听模式,而bigchaindb.log显示连接为tendermint:

代码语言:javascript
复制
[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)

净统计局的产出:

代码语言:javascript
复制
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进程会监听26657端口。

来自bigchaindb.log的Stacktrace:

代码语言:javascript
复制
[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。

代码语言:javascript
复制
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)

编辑-2:我尝试在日志级别设置为调试的情况下运行tendermint,并获得:

代码语言:javascript
复制
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服务器模块?

EN

回答 2

Stack Overflow用户

发布于 2020-07-21 11:47:02

尝试使用tendermint成因文件连接两个实例,然后提交事务。Tendermint无法找到事务的对等点。此外,还应该打开tendermint端口以允许事务处理。

票数 0
EN

Stack Overflow用户

发布于 2022-10-27 14:01:47

确保bigchaindb服务器在启动招标造币厂之前运行。

如果使用docker安装bigchaindb,可以执行以下操作:

  1. make stop
  2. make start
  3. make run

或者如果你不介意泄露你的数据

  1. make stop
  2. make clean
  3. make start
  4. make run

还要确保您允许所需的端口通过防火墙。

在您的计算机中通过防火墙添加端口26656,26657,26658,9984,9985,并运行

ufw allow 26656ufw allow 26657ufw allow 26658ufw allow 9984ufw allow 9985 on ssh

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61580896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档