Cause of error 1: Listeners were placed on global namespace socket manager instead of local ('socket-api') namespace manager. appendFile calls were not being executed.
Cause of error 2: Under the conditions of error 1, userID, visitID, logFileName, and logFilePath were not accessible to the local listener functions and came back undefined.
Cause of error 3: Unexpected behavior of class Queue (#dequeue method) See [airbug/airbug#70]
Details: When userID, visitID, logFileName, and logFilePath were being set on 'startTracking', the backwards dequeueing would cause 'tracklog' and 'disconnect' events to be received before the 'startTracking' event. logFilePath would be undefined and error.
socketManager.of('namespace') returns a local namespace object with has its own socket as a property
Fix: Move listeners to local namespace a.k.a. Manager object
And move the userID and visitID generation to the serverside
var ioManager = io.listen(server); //Global namespace
ioManager.set('match origin protocol', true); //NOTE: Only necessary for use with wss, WebSocket Secure protocol
ioManager.set('resource', '/socket-api'); //NOTE: forward slash is required here unlike client setting
ioManager
.of('/socket-api') // local namespace manager
.on('connection', function (socket) {
console.log("Connection established")
var userID = UuidGenerator.generateUuid();
var visitID = UuidGenerator.generateUuid();
var logFileName = userID + '-' + visitID + '.log';
var logFilePath = activeFoldersPath + '/' + logFileName;
Under certain conditions Files fail to write due to logFilePath === undefined This causes the server to crash and restart Example:
Cause of error 1: Listeners were placed on global namespace socket manager instead of local ('socket-api') namespace manager. appendFile calls were not being executed.
Cause of error 2: Under the conditions of error 1, userID, visitID, logFileName, and logFilePath were not accessible to the local listener functions and came back undefined.
Cause of error 3: Unexpected behavior of class Queue (#dequeue method) See [airbug/airbug#70] Details: When userID, visitID, logFileName, and logFilePath were being set on 'startTracking', the backwards dequeueing would cause 'tracklog' and 'disconnect' events to be received before the 'startTracking' event. logFilePath would be undefined and error.
socketManager.of('namespace') returns a local namespace object with has its own socket as a property Fix: Move listeners to local namespace a.k.a. Manager object And move the userID and visitID generation to the serverside
Secondary failsafe added: Example:
Local Test Plan
Production Test Plan
Example log file: (file name should be [userID]-[visitID].log)