volttron.platform.vip.agent.core ERROR: Possible conflicting identity

volttron.platform.vip.agent.core ERROR: Possible conflicting identity

我一直在努力培养我在 Volttron 中的代理开发技能。我是该平台的新手,正在尝试了解如何创建发布和订阅 Volttron 总线的基本代理。我在这个项目中并不孤单,我得到了其他一些有经验的人的帮助,但即使他们也被难住了。我们使用通过 GitHub 共享的相同代理文件,但代理在他们的计算机上工作,而不是在我的计算机上工作。

发布代理​​读取与代理位于同一目录中的 CSV 文件,并假设从该文件发布信息。我一直小心地将文件目录映射到我的源代码中以匹配我的设置。当我使用 运行ning 在 Linux Mint 18.1 Serena 上 运行ning 我的发布代理时,我收到以下消息:

2017-02-02 14:27:22,290 volttron.platform.agent.utils DEBUG: missing file /home/edward/.volttron/keystores/f9d18589-d62b-42b7-bac8-3498a0c37220/keystore.json

2017-02-02 14:27:22,290 volttron.platform.agent.utils INFO: creating file /home/edward/.volttron/keystores/f9d18589-d62b-42b7-bac8-3498a0c37220/keystore.json

2017-02-02 14:27:22,292 volttron.platform.vip.agent.core DEBUG: address: ipc://@/home/edward/.volttron/run/vip.socket

2017-02-02 14:27:22,292 volttron.platform.vip.agent.core DEBUG: identity: None

2017-02-02 14:27:22,292 volttron.platform.vip.agent.core DEBUG: agent_uuid: None

2017-02-02 14:27:22,292 volttron.platform.vip.agent.core DEBUG: severkey: None

2017-02-02 14:27:32,324 volttron.platform.vip.agent.core ERROR: No response to hello message after 10 seconds.

2017-02-02 14:27:32,324 volttron.platform.vip.agent.core ERROR: A common reason for this is a conflicting VIP IDENTITY.

2017-02-02 14:27:32,324 volttron.platform.vip.agent.core ERROR: Shutting down agent.

2017-02-02 14:27:32,324 volttron.platform.vip.agent.core ERROR: Possible conflicting identity is: f9d18589-d62b-42b7-bac8-3498a0c37220

我做了以下事情:

  1. 创建了丢失的文件“/home/edward/.volttron/keystores/f9d18589-d62b-42b7-bac8-3498a0c37220/keystore.json”。当我再次 运行 代理时,唯一发生的事情是它给了我相同的 DEBUG 消息,但文件名不同。

  2. 我查看了“volttron.platform.vip.agent.core”文件,不知道在里面做什么。我不想给自己制造更多的麻烦。

  3. 我一直在使用“Volttron 的文档”来尝试解决问题,但是每当我尝试 运行 任何代理时,我总是收到相同的消息。我在测试平台和通过终端运行宁“make-listener”时取得了成功,但仅此而已。

  4. 过去几天我一直在网上搜索并看到类似的问题,但是当我试图按照张贴的建议来补救这种情况时,我没有运气。

  5. 在我的 VM 上重新安装了几次 Volttron、Mint 和 Eclipse 以解决任何兼容性问题...

代理源码如下:

#testcodeisforpublishingandprinting
import logging
import sys
#import json
from volttron.platform.vip.agent import Agent, Core, PubSub, compat
#from volttron.platform.vip.agent import *
#from volttron.platform.vip.agent import compat
from volttron.platform.agent import utils
from volttron.platform.messaging import headers as headers_mod
from datetime import datetime
#import numpy as NP
#from numpy import linalg as LA

import csv
outdata=open("/home/edward/volttron/testagent/Agent/PredictionfileP.csv","rb")    
Pdata=csv.DictReader(outdata)
Price=[]
for row in Pdata:
    Price.append(float(row['Price'])*0.01)

#from volttron.platform.agent import BaseAgent, PublishMixin, periodic, matching, utils
#from volttron.platform.agent import BaseAgent, PublishMixin, periodic

utils.setup_logging()
_log = logging.getLogger(__name__)

class testagent1(Agent):
    def __init__(self, config_path, **kwargs):
        self.config = utils.load_config(config_path)
        super(testagent1, self).__init__(**kwargs)
        self.step=0
        #print('TestAgent example agent start-up function')
    @Core.receiver('onsetup')
    def onsetup(self, sender, **kwargs):
        self._agent_id = self.config['agentid']
    @Core.receiver('onstart')
    def onstart(self, sender, **kwargs):
        pass       
    @Core.receiver('onstop')
    def onstop(self, sender, **kwargs):
        pass    
    @Core.receiver('onfinish')
    def onfinish(self, sender, **kwargs):
        pass
    @Core.periodic(5)
    def simulate(self):
        self.step=self.step+1#timestep increase
        print('Simulationrunning')
    
        now = datetime.utcnow().isoformat(' ')#time now
        headers = {
            'AgentID': self._agent_id,
            headers_mod.CONTENT_TYPE: headers_mod.CONTENT_TYPE.PLAIN_TEXT,
            headers_mod.DATE: now,
        }
        print(self.step)
        self.vip.pubsub.publish('pubsub', 'testcase1/Step', headers, self.step) 
        print('Simulationupdatingloopingindex')
def main(argv=sys.argv):
    '''Main method called by the eggsecutable.'''
    try:
        utils.vip_main(testagent1)
    except Exception as e:
        _log.exception('unhandled exception')


if __name__ == '__main__':
    # Entry point for script
    sys.exit(main())

我使用 2017 年 1 月发布的 3.5RC1 手册安装了我的 Volttron 版本。

我假设您是 运行 来自 eclipse 而不是通过安装过程。代理的安装将指定一个将在代理的生命周期内保留的身份。

剩下的答案特定于 运行 在 eclipse 环境中。

def main(argv=sys.argv):
    '''Main method called by the eggsecutable.'''
    try:
        # This is where the change is.
        utils.vip_main(testagent1, identity='Thisidentity')
    except Exception as e:
        _log.exception('unhandled exception')

您必须通过身份验证机制添加代理公钥来授权代理能够连接到消息总线。或者您可以通过 volttron-ctl auth add.

将通配符 /.*/ 添加到条目的凭据中

感谢您提出这个问题。我们将更新文档以突出显示这一点。

您需要在命令行执行以下操作:

volttron-ctl auth add
domain []: 
address []: 
user_id []: 
capabilities (delimit multiple entries with comma) []: 
roles (delimit multiple entries with comma) []: 
groups (delimit multiple entries with comma) []: 
mechanism [CURVE]: 
credentials []: /.*/
comments []: 
enabled [True]: 
added entry domain=None, address=None, mechanism='CURVE', credentials=u'/.*/', user_id='ff6fea8e-53bd-4506-8237-fbb718aca70d'