【问题标题】:ContextBroker subscriptions ErrorContextBroker 订阅错误
【发布时间】:2017-10-03 13:13:56
【问题描述】:

我已按照本教程安装 NGSI,将 cygnus 从 0.13 版更新到 1.7.0:

https://github.com/telefonicaid/fiware-cygnus/tree/master/cygnus-ngsi

订阅错误

    [
        {
            "id": "59d38a92dbaa1e477aef9c00",
            "description": "A subscription to get info about pruebas",
            "status": "failed",
            "subject": {
                "entities": [
                    {
                        "id": "pruebas",
                        "type": "pruebas"
                    }
                ],
                "condition": {
                    "attrs": [
                        "pressure"
                    ]
                }
            },
            "notification": {
                "timesSent": 2,
                "lastNotification": "2017-10-03T13:03:43.00Z",
                "attrs": [
                    "temperature",
                    "pressure"
                ],
                "attrsFormat": "legacy",
                "http": {
                    "url": "http://localhost:5050/notify"
                },
                "lastFailure": "2017-10-03T13:03:43.00Z"
            }
        }
]

查看 contextBroker 日志会得到以下信息:

$pp[328]:notificationError | msg=Raising alarm NotificationError http://localhost:5050/notify: (curl_easy_perform failed: Couldn't connect to server)

我和 cygnus 在同一台机器上拥有 contextBroker,所以我已经尝试更改服务器和本地主机的通知 ip,但它对任何一个都不起作用。

如果它适用于 localhost,则使用版本 0.13。

可能是什么问题?

它甚至没有进入 cygnus 配置文件,因为它无法从 contextBroker 访问。

您好,谢谢。

EDIT1:

我使用 fiwareLab 机器进行了测试,并删除了 YUM REMOVE CYGNUS 预安装的 cygnus 0.13。然后我用 YUM INSTALL CYGNUS-NGSI 安装了 1.7 并安装了两个包 ngsi 和 common。

使用 service cygnus restart 重启服务表示如下:

Dependencies Resolved

================================================================================
 Package              Arch          Version                 Repository     Size
================================================================================
Installing:
 cygnus-ngsi          x86_64        1.7.1-0.g9df0d4d        fiware         74 M
Installing for dependencies:
 cygnus-common        x86_64        1.7.1-0.g9df0d4d        fiware        128 M

Transaction Summary
================================================================================
Install       2 Package(s)

Total size: 202 M
Installed size: 223 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
[INFO] Creating cygnus user
  Installing : cygnus-common-1.7.1-0.g9df0d4d.x86_64                        1/2
[INFO] Creating log directory
Done
  Installing : cygnus-ngsi-1.7.1-0.g9df0d4d.x86_64                          2/2
  Verifying  : cygnus-common-1.7.1-0.g9df0d4d.x86_64                        1/2
  Verifying  : cygnus-ngsi-1.7.1-0.g9df0d4d.x86_64                          2/2

Installed:
  cygnus-ngsi.x86_64 0:1.7.1-0.g9df0d4d

Dependency Installed:
  cygnus-common.x86_64 0:1.7.1-0.g9df0d4d

Complete!
[centos@centos6 cygnus]$ sudo service cygnus restart
There aren't any instance of Cygnus  running               [  OK  ]
Starting Cygnus 1...                                       [  OK  ]

当我在我的服务器上尝试时,我执行相同的步骤,但是在执行服务 cygnus restart 时有两个 cygnus 1 和 2 不像 vuesta 机器中只有一个,因此表明端口 8081 已在使用中。

Dependencias resueltas

============================================================================================================================================================================
 Paquete                                     Arquitectura                         Versión                                        Repositorio                          Tamaño
============================================================================================================================================================================
Instalando:
 cygnus-ngsi                                 x86_64                               1.7.1-0.g9df0d4d                               fiware                                74 M
Instalando para las dependencias:
 cygnus-common                               x86_64                               1.7.1-0.g9df0d4d                               fiware                               128 M

Resumen de la transacción
============================================================================================================================================================================
Instalar       2 Paquete(s)

Tamaño total de la descarga: 202 M
Tamaño instalado: 223 M
Está de acuerdo [s/N]:s
Descargando paquetes:
(1/2): cygnus-common_hadoopcore_1.2.1-1.7.1-0.g9df0d4d.x86_64.rpm                                                                                    | 128 MB     00:14     
(2/2): cygnus-ngsi-1.7.1-0.g9df0d4d.x86_64.rpm                                                                                                       |  74 MB     00:07     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                       8.9 MB/s | 202 MB     00:22     
Ejecutando el rpm_check_debug
Ejecutando prueba de transacción
La prueba de transacción ha sido exitosa
Ejecutando transacción
[INFO] Creating cygnus user
  Instalando    : cygnus-common-1.7.1-0.g9df0d4d.x86_64                                                                                                                 1/2 
[INFO] Creating log directory
Done
  Instalando    : cygnus-ngsi-1.7.1-0.g9df0d4d.x86_64                                                                                                                   2/2 
  Verifying     : cygnus-common-1.7.1-0.g9df0d4d.x86_64                                                                                                                 1/2 
  Verifying     : cygnus-ngsi-1.7.1-0.g9df0d4d.x86_64                                                                                                                   2/2 

Instalado:
  cygnus-ngsi.x86_64 0:1.7.1-0.g9df0d4d                                                                                                                                     

Dependencia(s) instalada(s):
  cygnus-common.x86_64 0:1.7.1-0.g9df0d4d                                                                                                                                   

¡Listo!


[root@UAL-IoF2020 conf]# ls
agent_1.conf         agent_ngsi.conf.template    cygnus_instance_2.conf         grouping_rules_2.conf         krb5_login.conf              README-cygnus-common.md
agent_3.conf         cartodb_keys.conf.template  cygnus_instance.conf.template  grouping_rules.conf.template  log4j.properties             README-cygnus-ngsi.md
agent.conf.template  cygnus_instance_1.conf      flume-env.sh.template          krb5.conf.template            name_mappings.conf.template
[root@UAL-IoF2020 conf]# service cygnus restart
There aren't any instance of Cygnus  running               [  OK  ]
Starting Cygnus 1...                                       [  OK  ]
Starting Cygnus 2...                                       [  OK  ]
[root@UAL-IoF2020 conf]# 

这是否可能是问题所在,并且无法识别我的 NGSI 并且占用了 8081 的公共空间?或者这是正常的吗?

日志天鹅座:

time=2017-10-03T21:51:09.326Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=main | msg=com.telefonica.iot.cygnus.nodes.CygnusApplication[301] : Starting a Jetty server listening on 0.0.0.0:8081 (Management Interface)
time=2017-10-03T21:51:09.381Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=warn | msg=org.mortbay.log.Slf4jLog[76] : failed SelectChannelConnector@0.0.0.0:8081: java.net.BindException: La dirección ya se está usando
time=2017-10-03T21:51:09.381Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=warn | msg=org.mortbay.log.Slf4jLog[76] : failed Server@52992ace: java.net.BindException: La dirección ya se está usando
time=2017-10-03T21:51:09.381Z | lvl=FATAL | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=run | msg=com.telefonica.iot.cygnus.http.JettyServer[90] : Fatal error running the Management Interface. Details=La dirección ya se está usando

EDIT2

我已经解决了两个cygnus的问题,创建了两个agent_1和agent_2。我已经删除了其中一个,并且已经执行 service cygnus restart 只出现了一个 cygnus。我们正在变得更好。

但我在订阅方面仍然遇到同样的问题:

contextBroker 日志表明:

 

msg = Raising alarm NotificationError http: // localhost: 5050 / notify: (curl_easy_perform failed: could not connect to server)

当我尝试时:

[root @ UAL-IoF2020 conf] # netstat -np | grep 5050

我什么都没想。

当我启动这个时:

[root @ UAL-IoF2020 conf] # netstat -np | grep 1026
tcp 0 0 150.XXX.XXX.XXX:1026 XXX.XXX.XXX.XXX:50348 ESTABLISHED 5169 / contextBroker

我正在尝试对您的网页进行测试。

./notification-json-simple.sh http: // localhost: 5050 / notify myservice myservicepath

并给我以下错误:

[root @ UAL-IoF2020 ngsi-examples] # ./notification-json-simple.sh http: // localhost: 5050 / notify myservice myservicepath
* About to connect () to localhost port 5050 (# 0)
* Trying :: 1 ... Connection refused
* Trying 127.0.0.1 ... Connection refused
* could not connect to host
* Closing connection # 0
curl: (7) could not connect to host

它给人的印象是在 5050 中我什么都听不到。

有什么线索吗?

cygnus-ngsi.sources = http-source
cygnus-ngsi.sinks = mysql-sink
cygnus-ngsi.channels = mysql-channel

#=============================================
# source configuration
# channel name where to write the notification events
cygnus-ngsi.sources.http-source.channels = mysql-channel
# source class, must not be changed
cygnus-ngsi.sources.http-source.type = org.apache.flume.source.http.HTTPSource
# listening port the Flume source will use for receiving incoming notifications
cygnus-ngsi.sources.http-source.port = 5050
# Flume handler that will parse the notifications, must not be changed
cygnus-ngsi.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
# URL target
cygnus-ngsi.sources.http-source.handler.notification_target = /notify
# default service (service semantic depends on the persistence sink)
cygnus-ngsi.sources.http-source.handler.default_service = default
# default service path (service path semantic depends on the persistence sink)
cygnus-ngsi.sources.http-source.handler.default_service_path = /
# source interceptors, do not change
cygnus-ngsi.sources.http-source.interceptors = ts gi
# TimestampInterceptor, do not change
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp
# GroupingInterceptor, do not change
cygnus-ngsi.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor$Builder
# Grouping rules for the GroupingInterceptor, put the right absolute path to the file if necessary
# see the doc/design/interceptors document for more details
cygnus-ngsi.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf

【问题讨论】:

  • Orion 报告该错误意味着它无法到达通知端点。您是否测试过端点是否正常(例如,使用telnet 连接到该主机以及来自运行 Orion 的主机的端口)? Cygnus 日志中有任何痕迹吗? Cygnus 是否配置为在 5050 中侦听(检查 Cygnus 配置)?
  • 您发布的最后一个错误日志是关键:有另一个正在运行的进程正在侦听 TCP/5050 端口。很可能,之前的 Cygnus 运行没有正确停止/杀死。
  • netstat -np | grep 5050 应该显示一个 Cygnus 进程。否则,notification-json-simple.sh 失败是正常的,因为您的主机中没有人在监听 5050。
  • 我觉得我也是jajaja,感觉很重,但是怎么解决呢?我安装了cygnus并配置了代理我不知道还能做什么。 :(
  • 要从 0 开始安装,我执行了以下步骤: yum install contextBroker yum install cygnus-ngsi 仅此而已。我必须安装 cygnus-common 手册吗?或风格的东西?我不知道还有什么可以解决这个问题。 @fgalan

标签: fiware fiware-orion fiware-cygnus


【解决方案1】:

我必须安装 cygnus-common 手册吗?

阅读文档 (https://github.com/telefonicaid/fiware-cygnus/tree/master/cygnus-ngsi) 它写道:

Cygnus NGSI 基于 Apache Flume,通过 cygnus-common 使用,Cygnus NGSI 依赖。

我认为你需要安装 cygnus-common。

【讨论】:

    【解决方案2】:

    我已经解决了这个问题。 在cygnus_instance_1.conf的配置文件里,你得用cygnus-ngsi重命名cygnusagent代理。

    对于安装,我只是按照这些步骤操作。

    1. 安装 ContextBroker。
    2. 安装 MongoDB(用于 contextBroker 到 工作)。
    3. 安装 cygnus-ngsi,这又会自动安装 cygnus-common。

    4. 复制 agent_ngsi.conf.template 并将其重命名为 agent_1.conf

    5. 将 cygnus_instance.conf.template 复制到 cygnus_instance_1.conf

    6. 将代理从 cygnus_instance_1.conf 重命名为 cygnus-ngsi 和上面创建的配置文件 (agent_1.conf)

    这一切都通过 Yum 安装,通过 RPM,我不必安装 apache flume 或任何东西,这样它会自动完成所有事情。

    希望对您有所帮助,谢谢。

    【讨论】:

      【解决方案3】:

      您发布的最后一个错误日志是关键:有另一个正在运行的进程正在侦听 TCP/5050 端口。很可能,之前的 Cygnus 运行没有正确停止/杀死。

      【讨论】:

      • 要从 0 开始安装,我执行了以下步骤: yum install contextBroker yum install cygnus-ngsi 仅此而已。我必须安装 cygnus-common 手册吗?或风格的东西?我不知道还有什么可以解决这个问题
      • 安装cygnus-ngsi 时,会安装cygnus-common 作为依赖项。安装后,除了配置之外,无需进行任何其他操作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      • 2017-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      相关资源
      最近更新 更多