You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When an AgvController is stopped and then started again, the application throws an error. This also happens if we wait a while between stop and start.
Is this a regression?
Afaik not
To Reproduce
With an mqtt broker running on localhost:1883, run the following script:
import{VirtualAgvAdapterOptions}from'./../dist/adapter/virtual-agv-adapter.d';import{AgvId}from'./../dist/common/client-types.d';import{ClientOptions}from'./../dist/common/client.d';import{VirtualAgvAdapter}from'./adapter/virtual-agv-adapter';import{AgvController}from'./controller/agv-controller';(async()=>{// Use minimal client options: communication namespace and broker endpoint address.constagvClientOptions: ClientOptions={interfaceName: "logctx42",transport: {brokerUrl: "mqtt://localhost:1883"},vdaVersion: "2.0.0"};// The target AGV.constagvId001: AgvId={manufacturer: "RobotCompany",serialNumber: "001"};// Specify associated adapter type; use defaults for all other AGV controller options. constagvControllerOptions={agvAdapterType: VirtualAgvAdapter,};// Use defaults for all adapter options of Virtual AGV adapter.constagvAdapterOptions: VirtualAgvAdapterOptions={};// Create instance of AGV Controller with client, controller, and adapter options.constagvController=newAgvController(agvId001,agvClientOptions,agvControllerOptions,agvAdapterOptions);constsleep=asynct=>{awaitnewPromise(r=>setTimeout(r,1000*t))}awaitagvController.start();awaitsleep(5)awaitagvController.stop();awaitsleep(5)awaitagvController.start();})()
Expected behavior
The AgvController restarts without throwing an error.
Screenshots
C:\Repositories\vda-5050-lib.js\src\common\client.ts:712
throw new Error("Client is not started");
^
Error: Client is not started
at AgvController.publishTopic (C:\Repositories\vda-5050-lib.js\src\common\client.ts:712:19)
at AgvController.publish (C:\Repositories\vda-5050-lib.js\src\client\agv-client.ts:63:21)
at AgvController._publishCurrentState (C:\Repositories\vda-5050-lib.js\src\controller\agv-controller.ts:1216:43)
at AgvController._connectionStateChangeCallback (C:\Repositories\vda-5050-lib.js\src\controller\agv-controller.ts:1178:22)
at AgvController._emitConnectionStateChange (C:\Repositories\vda-5050-lib.js\src\common\client.ts:1186:18)
at MqttClient.<anonymous> (C:\Repositories\vda-5050-lib.js\src\common\client.ts:1130:26)
at MqttClient.emit (node:events:526:35)
at MqttClient.emit (node:domain:488:12)
at Readable.<anonymous> (C:\Repositories\vda-5050-lib.js\node_modules\mqtt\lib\client.js:1857:14)
at Readable.emit (node:events:514:28)
Your Environment (please complete the following information):
Package Version: 1.4.0
Node.js Version: 20.10.0
OS: Windows 10
Additional context
When the mqtt client connects on the second start, a publish state is triggered:
this._emitConnectionStateChange("online");
in \src\common\client.ts l.1131.
However this._isStarted is only set to true after connecting the mqtt broker in \src\common\client.ts l.472, leading to the error in AgvController.publishTopic.
A possible solution would be to set this._isStarted to true when the mqtt client connects, but before it emits the connection state change:
Describe the bug
When an AgvController is stopped and then started again, the application throws an error. This also happens if we wait a while between stop and start.
Is this a regression?
Afaik not
To Reproduce
With an mqtt broker running on localhost:1883, run the following script:
Expected behavior
The AgvController restarts without throwing an error.
Screenshots
Your Environment (please complete the following information):
Additional context
When the mqtt client connects on the second start, a publish state is triggered:
in
\src\common\client.ts
l.1131.However
this._isStarted
is only set totrue
after connecting the mqtt broker in\src\common\client.ts l.472
, leading to the error inAgvController.publishTopic
.A possible solution would be to set
this._isStarted
totrue
when the mqtt client connects, but before it emits the connection state change:in
\src\common\client.ts
ll.1129-1132.The text was updated successfully, but these errors were encountered: