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
In cases where an endpoint is offline but the script is still running it generates a client socket uncaught exception. This is using SSH to long term monitor events from an endpoint. Error is below.
2018-09-04T17:28:19.330Z error: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (client-socket)
at XAPI.emit (events.js:171:17)
at TSHBackend. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/xapi/index.js:126:13)
at TSHBackend.emit (events.js:182:13)
at DuplexPassThrough. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/backend/tsh.js:106:20)
at DuplexPassThrough.emit (events.js:182:13)
at Client. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/transport/ssh.js:106:15)
at Client.emit (events.js:182:13)
at Socket. (/Users/christno/WebstormProjects/walmartApp/node_modules/ssh2/lib/client.js:299:10)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
The text was updated successfully, but these errors were encountered:
It seems this specific case was caused by delayed execution of the handler for the emitted error event.
The reason for this is due to some nuances in the javascript language, and the fact that javascript is single threaded. Our transport layer, in this case ssh2, implements all of its logic, including the connect logic, in an asynchronous manner.
This means that, in the following example, xapi.on is actually executed before the ssh client connects. We will, in other words, always assign the error handler before it is used.
The fact that we're forcing the consumer of the APIs to set the error handler right after the connect, is very prone for error, and I suggest that in future versions, we'll change the API slightly, so that it is possible to establish handler before triggering the connect.
An example, though not the final design, of such a solution, might be something like:
In cases where an endpoint is offline but the script is still running it generates a client socket uncaught exception. This is using SSH to long term monitor events from an endpoint. Error is below.
2018-09-04T17:28:19.330Z error: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (client-socket)
at XAPI.emit (events.js:171:17)
at TSHBackend. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/xapi/index.js:126:13)
at TSHBackend.emit (events.js:182:13)
at DuplexPassThrough. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/backend/tsh.js:106:20)
at DuplexPassThrough.emit (events.js:182:13)
at Client. (/Users/christno/WebstormProjects/walmartApp/node_modules/jsxapi/lib/transport/ssh.js:106:15)
at Client.emit (events.js:182:13)
at Socket. (/Users/christno/WebstormProjects/walmartApp/node_modules/ssh2/lib/client.js:299:10)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
The text was updated successfully, but these errors were encountered: