如何解决opcagent 无法连接到汽车服务器
我在 iotagent-opcua
上运行我的 kubernetes env
,在部署 yml
文件后 opcua agent
无法连接到 server
,而是提供以下错误日志:
Please check that client certificate is trusted by server.
Err = (getaddrinfo ENOTFOUND test_machine_ip test_machine_ip:5001)
完整日志:
***********************************************
WARNING: It is recommended to enable authentication for secure connection
***********************************************
INFO: IoT Agent running standalone
time=2021-03-02T10:40:29.690Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=----------------------------------------------------
time=2021-03-02T10:40:29.691Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=endpointUrl = opc.tcp://TEST_MACHINE_IP:5001/UA/CarServer
time=2021-03-02T10:40:29.691Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=securityMode = None
time=2021-03-02T10:40:29.691Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=securityPolicy = http://opcfoundation.org/UA/SecurityPolicy#None
time=2021-03-02T10:40:29.691Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=timeout = -1
{"op":"IoTAgentNGSI.CommonConfig","time":"2021-03-02T10:40:29.693Z","lvl":"INFO","msg":"Setting IOTA_CB_HOST to environment value: orion"}
{"op":"IoTAgentNGSI.CommonConfig","time":"2021-03-02T10:40:29.694Z","msg":"Setting IOTA_CB_PORT to environment value: 1026"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_NORTH_PORT to environment value: 4001"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_PROVIDER_URL to environment value: http://iotage:4001"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_REGISTRY_TYPE to environment value: mongodb"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_DEFAULT_RESOURCE to environment value: /iot/devices"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_MONGO_HOST to environment value: mongo-common-0.mongo-common,mongo-common-1.mongo-common,mongo-common-2.mongo-common"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_MONGO_PORT to environment value: 27017"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_MONGO_DB to environment value: iotage"}
{"op":"IoTAgentNGSI.CommonConfig","msg":"Setting IOTA_MONGO_REPLICASET to environment value: rs0"}
{"op":"IoTAgentNGSI.Global","msg":"Activating IOT Agent NGSI Library."}
{"op":"IoTAgentNGSI.Global","msg":"MongoDB Device registry selected for NGSI Library"}
{"op":"IoTAgentNGSI.DbConn","time":"2021-03-02T10:40:29.705Z","msg":"First connection attempt"}
{"op":"IoTAgentNGSI.DbConn","msg":"Attempting to connect to MongoDB instance. Attempt 1"}
(node:6) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated,and will be removed in a future version. To use the new Server Discover and Monitoring engine,pass option { useUnifiedTopology: true } to the MongoClient constructor.
time=2021-03-02T10:40:29.765Z | lvl=INFO | corr=n/a | trans=n/a | op=n/a | msg=Express server listening on :::8080
(node:6) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
{"op":"IoTAgentNGSI.DbConn","time":"2021-03-02T10:40:29.882Z","msg":"Successfully connected to MongoDB."}
{"op":"IoTAgentNGSI.NorthboundServer","time":"2021-03-02T10:40:29.901Z","msg":"Starting IoT Agent listening on port [4001]"}
{"op":"IoTAgentNGSI.ContextServer","time":"2021-03-02T10:40:29.902Z","msg":"Loading NGSI Contect server routes"}
time=2021-03-02T10:40:29.908Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=Options = None http://opcfoundation.org/UA/SecurityPolicy#None
time=2021-03-02T10:40:29.909Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connecting to opc.tcp://TEST_MACHINE_IP:5001/UA/CarServer
time=2021-03-02T10:40:29.924Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 0 time ... We will retry in 2000 ms
time=2021-03-02T10:40:31.931Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 1 time ... We will retry in 4000 ms
time=2021-03-02T10:40:35.939Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 2 time ... We will retry in 8000 ms
time=2021-03-02T10:40:43.943Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 3 time ... We will retry in 10000 ms
time=2021-03-02T10:40:53.949Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 4 time ... We will retry in 10000 ms
time=2021-03-02T10:41:03.955Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 5 time ... We will retry in 10000 ms
time=2021-03-02T10:41:13.963Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 6 time ... We will retry in 10000 ms
time=2021-03-02T10:41:23.967Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 7 time ... We will retry in 10000 ms
time=2021-03-02T10:41:33.974Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 8 time ... We will retry in 10000 ms
time=2021-03-02T10:41:43.978Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= connection failed for the 9 time ... We will retry in 10000 ms
time=2021-03-02T10:41:53.984Z | lvl=ERROR | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= disconnected
time=2021-03-02T10:41:53.984Z | lvl=ERROR | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= client : process terminated with an error
time=2021-03-02T10:41:53.984Z | lvl=ERROR | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= error Error: The connection has been rejected by server,Please check that client certificate is trusted by server.
Err = (getaddrinfo ENOTFOUND test_machine_ip test_machine_ip:5001)
at _internal_create_secure_channel (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:463:27)
at async.series (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:413:17)
at err (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:2959:19)
at wrapper (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:272:20)
at iterateeCallback (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:417:21)
at /opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:325:20
at result (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:2957:17)
at secureChannel.create (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:385:21)
at _establish_connection (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:275:24)
at ClientSecureChannelLayer._backoff_completion (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:678:17)
at completionFunc (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:735:25)
at FunctionCall.doCallback_ (/opt/iotagent-opcua/node_modules/backoff/lib/function_call.js:162:20)
at Backoff.emit (events.js:198:13)
at Backoff.EventEmitter.emit (domain.js:466:23)
at Backoff.backoff (/opt/iotagent-opcua/node_modules/backoff/lib/backoff.js:41:14)
at FunctionCall.handleFunctionCallback_ (/opt/iotagent-opcua/node_modules/backoff/lib/function_call.js:178:23)
time=2021-03-02T10:41:53.986Z | lvl=ERROR | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= stack trace Error: The connection has been rejected by server,Please check that client certificate is trusted by server.
Err = (getaddrinfo ENOTFOUND test_machine_ip test_machine_ip:5001)
at _internal_create_secure_channel (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:463:27)
at async.series (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:413:17)
at err (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:2959:19)
at wrapper (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:272:20)
at iterateeCallback (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:417:21)
at /opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:325:20
at result (/opt/iotagent-opcua/node_modules/node-opcua-client/node_modules/async/dist/async.js:2957:17)
at secureChannel.create (/opt/iotagent-opcua/node_modules/node-opcua-client/dist/private/client_base_impl.js:385:21)
at _establish_connection (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:275:24)
at ClientSecureChannelLayer._backoff_completion (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:678:17)
at completionFunc (/opt/iotagent-opcua/node_modules/node-opcua-secure-channel/dist/source/client/client_secure_channel_layer.js:735:25)
at FunctionCall.doCallback_ (/opt/iotagent-opcua/node_modules/backoff/lib/function_call.js:162:20)
at Backoff.emit (events.js:198:13)
at Backoff.EventEmitter.emit (domain.js:466:23)
at Backoff.backoff (/opt/iotagent-opcua/node_modules/backoff/lib/backoff.js:41:14)
at FunctionCall.handleFunctionCallback_ (/opt/iotagent-opcua/node_modules/backoff/lib/function_call.js:178:23)
time=2021-03-02T10:41:53.986Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg= Check Security Settings null
time=2021-03-02T10:41:53.987Z | lvl=INFO | corr=n/a | trans=n/a | op=Index.Initialize | comp=iotAgent-OPCUA | srv=n/a | subsrv=n/a | msg=Exiting
这部分已经按照描述完成了:
According to the OPC UA Security Model the OPC UA IotAgent,acting as an OPC UA Client,can specify a "Security Policy" and a "Security Mode". Nevertheless,these requests must find a match with the OPC UA Server policies.
You can specify the Security Policy/Mode pair through the config.properties file,and in particular by modifying this section:
## SERVER CERT E AUTH
securityMode=None
securityPolicy=None
userName=
password=
我部署的yaml文件如下,供参考:
---
apiVersion: v1
kind: Service
metadata:
name: iotcarsrv
spec:
type: NodePort
# type: ClusterIP
ports:
- port: 5001
name: tcp5001to5001
protocol: TCP
targetPort: 5001
selector:
app: iotcarsrv
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: iotcarsrv-deployment
spec:
replicas: 1
selector:
matchLabels:
app: iotcarsrv
template:
metadata:
labels:
app: iotcarsrv
spec:
containers:
- name: iotcarsrv
image: iotagent4fiware/opcuacarsrv:1.3.4
imagePullPolicy: Always
# args: ["-dbhost","mongo-common-0.mongo-common,mongo-common-2.mongo-common","-rplSet","rs0","-logLevel","DEBUG"]
resources:
limits:
cpu: 500m
requests:
cpu: 200m
ports:
- containerPort: 5001
protocol: TCP
env:
- name: IOTA_CB_HOST
value: "orion"
- name: IOTA_CB_PORT
value: "1026"
- name: IOTA_NORTH_PORT
value: "5001"
- name: IOTA_REGISTRY_TYPE
value: "mongodb"
- name: IOTA_MONGO_HOST
value: "mongo-common-0.mongo-common,mongo-common-2.mongo-common"
- name: IOTA_MONGO_PORT
value: "27017"
- name: IOTA_MONGO_DB
value: "iotcarsrv"
- name: IOTA_MONGO_REPLICASET
value: "rs0"
- name: IOTA_PROVIDER_URL
value: "http://iotcarsrv:5001"
- name: IOTA_DEFAULT_RESOURCE
value: "/iot/devices"
# volumeMounts:
# - mountPath: /nas1/iotagent-json/iotajson
# name: persistent-config
# - mountPath: /etc/localtime
# name: persistent-localtime
# readOnly: true
# livenessProbe:
# failureThreshold: 3
# initialDelaySeconds: 10
# periodSeconds: 10
# successThreshold: 1
# tcpSocket:
# port: 5001
# timeoutSeconds: 2
# nodeSelector:
# scfw.cluster.id: stdap
# volumes:
# - persistentVolumeClaim:
# claimName: iota-persistent-config
# name: persistent-config
# - hostPath:
# path: /etc/localtime
# type: FileOrCreate
# name: persistent-localtime
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: iotcarsrv
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: iotcarsrv
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
---
---
apiVersion: v1
kind: Service
metadata:
name: iotage
spec:
type: NodePort
# type: ClusterIP
ports:
- port: 4001
name: tcp4001to4001
protocol: TCP
targetPort: 4001
selector:
app: iotage
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: iotage-deployment
spec:
replicas: 1
selector:
matchLabels:
app: iotage
template:
metadata:
labels:
app: iotage
spec:
containers:
- name: iotage
image: iotagent4fiware/iotagent-opcua:1.3.4
# args: ["-dbhost","DEBUG"]
resources:
limits:
cpu: 500m
requests:
cpu: 200m
ports:
- containerPort: 4001
protocol: TCP
env:
- name: IOTA_CB_HOST
value: "orion"
- name: IOTA_CB_PORT
value: "1026"
- name: IOTA_NORTH_PORT
value: "4001"
- name: IOTA_REGISTRY_TYPE
value: "mongodb"
- name: IOTA_MONGO_HOST
value: "mongo-common-0.mongo-common,mongo-common-2.mongo-common"
- name: IOTA_MONGO_PORT
value: "27017"
- name: IOTA_MONGO_DB
value: "iotage"
- name: IOTA_MONGO_REPLICASET
value: "rs0"
- name: IOTA_PROVIDER_URL
value: "http://iotage:4001"
- name: IOTA_DEFAULT_RESOURCE
value: "/iot/devices"
# volumeMounts:
# - mountPath: /nas1/iotagent-json/iotajson
# name: persistent-config
# - mountPath: /etc/localtime
# name: persistent-localtime
# readOnly: true
#livenessProbe:
# failureThreshold: 3
# initialDelaySeconds: 10
# periodSeconds: 10
# successThreshold: 1
# tcpSocket:
# port: 4001
# timeoutSeconds: 2
# nodeSelector:
# scfw.cluster.id: stdap
# volumes:
# - persistentVolumeClaim:
# claimName: iota-persistent-config
# name: persistent-config
# - hostPath:
# path: /etc/localtime
# type: FileOrCreate
# name: persistent-localtime
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: iotage
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: iotage
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
---
需要与此错误 opcua 相关的任何帮助或任何文档。提前致谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。