TriggerCMD on Openwrt
- 
					
					
					
					
 Good evening all, 
 I tried to install only the agent on Openwrt by following these steps:- installed packeges: node-npm, git-http
- created new folder called gitrepo
 3)into the new folder (gitrepo) I executed the git command: git clone https://github.com/rvmey/TRIGGERcmd-Agent.git
- into the subfolder TRIGGERcmd-AgentI executed the command: "node ./src/agent.js --console" to verify missing modules
- the missing modules installed with npm have been: socket.io-client, sails.io.js, request, prompt, chokidar
 6)then I executed againg the command: "node ./src/agent.js --console" and inserted the token I obtained these rows: Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
 Daemon install: false
 Logging in with saved token.
 Checking if the computer exists.
 This computer exists in your account.
 Tokenfile: /root/.TRIGGERcmdData/token.tkn
 ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
 Logging in with saved token to run foreground tasks.
 Local Home Assistant Configuration file not found at /root/.TRIGGERcmdData/home_assistant_config.json
 Local Home Assistant listener is disabled.
 Write backup completed.The socket was unable to connect. 
 The server may be offline, or the
 socket may have failed authorization
 based on its origin or other factors.
 You may want to check the values of
 sails.config.sockets.onlyAllowOrigins
 or (more rarely)sails.config.sockets.beforeConnect
 in your app.
 More info: https://sailsjs.com/config/sockets
 For help: https://sailsjs.com/supportTechnical details:
 TransportError: websocket error
 at WS.onError (/root/node_modules/engine.io-client/build/cjs/transport.js:48:37)
 at ws.onerror (/root/node_modules/engine.io-client/build/cjs/transports/websocket.js:57:39)
 at callListener (/root/node_modules/ws/lib/event-target.js:290:14)
 at WebSocket.onError (/root/node_modules/ws/lib/event-target.js:230:9)
 at WebSocket.emit (node:events:517:28)
 at emitErrorAndClose (/root/node_modules/ws/lib/websocket.js:1035:13)
 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
 description: ErrorEvent {
 [Symbol(kTarget)]: WebSocket {
 _events: [Object: null prototype],
 _eventsCount: 4,
 _maxListeners: undefined,
 _binaryType: 'nodebuffer',
 _closeCode: 1006,
 _closeFrameReceived: false,
 _closeFrameSent: false,
 _closeMessage: <Buffer >,
 _closeTimer: null,
 _extensions: {},
 _paused: false,
 _protocol: '',
 _readyState: 2,
 _receiver: null,
 _sender: null,
 _socket: null,
 _bufferedAmount: 0,
 _isServer: false,
 _redirects: 0,
 _autoPong: true,
 _url: 'wss://www.triggercmd.com/engine.io/?EIO=4&transport=websocket',
 _req: [ClientRequest],
 [Symbol(kCapture)]: false
 },
 [Symbol(kType)]: 'error',
 [Symbol(kError)]: Error: Unexpected server response: 404
 at ClientRequest.<anonymous> (/root/node_modules/ws/lib/websocket.js:912:7)
 at ClientRequest.emit (node:events:517:28)
 at HTTPParser.parserOnIncomingClient (node:_http_client:700:27)
 at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
 at TLSSocket.socketOnData (node:_http_client:541:22)
 at TLSSocket.emit (node:events:517:28)
 at addChunk (node:internal/streams/readable:368:12)
 at readableAddChunk (node:internal/streams/readable:341:9)
 at Readable.push (node:internal/streams/readable:278:10)
 at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23),
 [Symbol(kMessage)]: 'Unexpected server response: 404'
 },
 context: undefined,
 type: 'TransportError'
 }Computer name for Local Home Assistant listener: null
 Error fetching computer name: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
 at Object.writeFile (node:fs:2269:5)
 at /root/gitrepo/TRIGGERcmd-Agent/src/ha.js:120:10
 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
 code: 'ERR_INVALID_ARG_TYPE'
 }
 Initiated command removals
 Initiated command adds
 Failed while trying add a trigger.
 Failed while trying add a trigger.
 ^C
 root@OpenWrt:~/gitrepo/TRIGGERcmd-Agent# node ./src/agent.js --console
 Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
 Daemon install: false
 Logging in with saved token.
 Checking if the computer exists.
 This computer exists in your account.
 Tokenfile: /root/.TRIGGERcmdData/token.tkn
 ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
 Logging in with saved token to run foreground tasks.
 Local Home Assistant listener is disabled.
 Write backup completed.
 Computer name for Local Home Assistant listener: null
 Error fetching computer name: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
 at Object.writeFile (node:fs:2269:5)
 at /root/gitrepo/TRIGGERcmd-Agent/src/ha.js:120:10
 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
 code: 'ERR_INVALID_ARG_TYPE'
 }
 Initiated command removalsThe socket was unable to connect. 
 The server may be offline, or the
 socket may have failed authorization
 based on its origin or other factors.
 You may want to check the values of
 sails.config.sockets.onlyAllowOrigins
 or (more rarely)sails.config.sockets.beforeConnect
 in your app.
 More info: https://sailsjs.com/config/sockets
 For help: https://sailsjs.com/supportTechnical details:
 TransportError: websocket error
 at WS.onError (/root/node_modules/engine.io-client/build/cjs/transport.js:48:37)
 at ws.onerror (/root/node_modules/engine.io-client/build/cjs/transports/websocket.js:57:39)
 at callListener (/root/node_modules/ws/lib/event-target.js:290:14)
 at WebSocket.onError (/root/node_modules/ws/lib/event-target.js:230:9)
 at WebSocket.emit (node:events:517:28)
 at emitErrorAndClose (/root/node_modules/ws/lib/websocket.js:1035:13)
 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
 description: ErrorEvent {
 [Symbol(kTarget)]: WebSocket {
 _events: [Object: null prototype],
 _eventsCount: 4,
 _maxListeners: undefined,
 _binaryType: 'nodebuffer',
 _closeCode: 1006,
 _closeFrameReceived: false,
 _closeFrameSent: false,
 _closeMessage: <Buffer >,
 _closeTimer: null,
 _extensions: {},
 _paused: false,
 _protocol: '',
 _readyState: 2,
 _receiver: null,
 _sender: null,
 _socket: null,
 _bufferedAmount: 0,
 _isServer: false,
 _redirects: 0,
 _autoPong: true,
 _url: 'wss://www.triggercmd.com/engine.io/?EIO=4&transport=websocket',
 _req: [ClientRequest],
 [Symbol(kCapture)]: false
 },
 [Symbol(kType)]: 'error',
 [Symbol(kError)]: Error: Unexpected server response: 404
 at ClientRequest.<anonymous> (/root/node_modules/ws/lib/websocket.js:912:7)
 at ClientRequest.emit (node:events:517:28)
 at HTTPParser.parserOnIncomingClient (node:_http_client:700:27)
 at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
 at TLSSocket.socketOnData (node:_http_client:541:22)
 at TLSSocket.emit (node:events:517:28)
 at addChunk (node:internal/streams/readable:368:12)
 at readableAddChunk (node:internal/streams/readable:341:9)
 at Readable.push (node:internal/streams/readable:278:10)
 at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23),
 [Symbol(kMessage)]: 'Unexpected server response: 404'
 },
 context: undefined,
 type: 'TransportError'
 }Initiated command adds 
 Failed while trying add a trigger.
 Failed while trying add a trigger.- on my account now I can see the openwrt instance but with the red icon and it isn't working.
 Can help me to let daemon working proprly please? Thanks for support 
 Egidio
- 
					
					
					
					
 @eromano , give me some time. I'll see if I can make it work on openwrt. 
- 
					
					
					
					
 @Russ yes sure, thank you 
- 
					
					
					
					
 @eromano, I tried to install OpenWRT on a VMWare VM for a while. I got version 15 installed using an OVA but I couldn't get openssl working, so I couldn't install nodejs etc on it. Anyway, I noticed your error output shows it's trying to access a URI that starts with /engine.io . That's not valid URI. I wonder if you've upgraded socket.io-client beyond the version specified in ubuntupackage.json because this article says the latest version 'socket.io-client@4.X.X uses /engine.io instead of the valid /socket.io URI. 
