You • kulveer i am once again requesting some time to work independently alone without meeting without interruptions let me just focus. Kulveer Virk • ok, when will you share the findings? Daiyaan? What are you working on today? We met and Tiago provided the demo and it is acceptable to business. We need to find out cause for Nest crashes. Let me know if you can provide me update for my 12 pm meeting. If any issue or other constraint, please let me know immediately. You • In the ui.gateway.ts file, there's a function called handleDisconnect() that handles the disconnection of the established websocket connection between the browser and the Nest server. Its purpose is to ensure that Nest is shut down when the customer closes the browser, as they perceive it as closing the application. Before shutting down Nest, the function performs validation checks to handle expected disconnections. One specific check is to determine if the reason for the browser losing connection is due to a logout action. This is tracked as part of the user interaction during the authentication flow. If the disconnection is related to a logout, such as when the browser redirects to an external site, the process is not terminated. Instead, the user is allowed to return to the browser and reconnect. However, for all other cases of disconnection via websocket, the Nest process is terminated. By implementing these checks, the handleDisconnect() function ensures the appropriate handling of disconnections based on their underlying causes. We encountered an issue where the Nest server crashes when the machine goes into hibernate mode. This problem is likely caused by the disconnection of the websocket that connects the browser to the Nest server. When the machine goes into hibernate mode, the websocket connection between the browser and the Nest server is disrupted, leading to a disconnection. This sudden disconnection can trigger a crash in the Nest server, resulting in unexpected behavior. To address this issue, we need to investigate the handling of websocket disconnections and ensure that the Nest server gracefully handles such scenarios, including hibernate-related disconnections. By implementing appropriate measures to handle disconnections, we can prevent crashes and ensure the stability of the Nest server even during hibernate events. We have identified another possible reason for the Nest server crashes during hibernate events. It could be related to the lifetime of the websocket connection. Websocket connections typically have a defined lifetime, and if we exceed that timeframe without re-establishing the connection, it can result in disconnections and potentially cause the Nest server to crash. To address this issue, we need to investigate the expected lifetime of the websocket connections in NestJS. By understanding the expected lifespan of these connections, we can implement appropriate strategies to manage and refresh the connections before they reach their expiration. This research will help us ensure the stability and uninterrupted operation of the Nest server, even during hibernate events. Kulveer Virk • Is there any solution that you have in mind? You • I need to reproduce, I can't reproduce my client has been connected for hours take a look at the length length = 1 that means one packet being sent we can confirm we have an autoconnect feature Kulveer Virk • close the laptop screen You • that maintains our websocket connection i tried going to sleep ok i will close laptop screen and see closed laptop screen its 2pm will wait for it to poll again i see it the second one is a new connection i see what you're saying when laptop screen is closed. we lose connection, it re-established connection for me nest server didnt crash though what it did was it re-established the connection, because I made a fix for it on my version. I don't kill the nest server if the user is not SIGNED IN. If signed in, and user closes the application, the nest server dies. If the user is signing out, and the application disconnects during redirect (on the way back to application), i don''t kill the nest server either. But logically, it would kill at this point once i close my laptop screen. We have two options: 1. Kill nest process by detecting if the browser is closed, if user switched to another tab in the same browser app (somehow), or if the device is put to sleep (*) using a library like this https://github.com/serkanyersen/ifvisible.js/ - we can check to see from the browser instead of checking the connection established from nest. If the browser is CLOSED (instead of losing connection with nest), we can send an event to nest for process kill. 2. Do some research into checking to see if theres a way with current implementation of websockets do identify if we can prevent the disconnection from instances where the laptop screen is closed. In summary, there are a lot of things that will kill our websocket's TCP connection. Browsers may put an inactive tab to sleep in order to save battery. That is also the case. Another thing to note is we don't plan on using websockets for long Kulveer Virk • Do websockets kill the connection and when we open the screen, we can not revive or refresh? You • Yeah so when laptop screen is closed, the websocket connection is killed from the BROWSER to nest. the websocket server (on nest) is still alive I have a listener for handling DISCONNECTS and so i can track when the browser loses connection to nest server what i have implemented is, when the BROWSER loses websocket connection with NEST then we PURPOSELY kill the connection Kulveer Virk • why would it kill? does it send any signal that internet is disconnected or any scenario? You • because think of the customer just closing the browser, they think they are closing the application, they aren't. So we want to close nest. but the issue is, we lose connection when we close the screen Kulveer Virk • Can we no purposely kill the session You • yes we can avoid it i just thought it wasn't proper architecture for enterprise so i accommodated for this i can prevent purposely killing the nest server when browser closes be advised this means that user can open the application in another browser and connect by typing the localhost with port also be advised when user closes browser nest server will still be running update: I can prevent multiple browsers from connecting so i can make it so the one we launch with is the only one that can connect to nest so if user opens a new chrome or edge and goes to localhost:port, they cannot communicate with nest because it will already be connected to the one we initially launched with so thats good news but what remains is that nest will be alive still when we close the browser we launch the application with but i can make it so no other browser can connect to it but they can still get to the login screen ui page, just nothing would happen if they clicked continue with sso etc. what we can do is find another way to keep track of the process i have another idea.... we can grab the process of the browser and in our websocket disconnect handler, whenever laptop closes screen we can check to see if the process tied to our browser (match it with process window title to ensure its ford upfitter) still exists if process still exists dont kill nest server. thats the solution. because now, we can still kill nest server if browser closes because in that case, process doesn't exist. because im going to be honest we want that functionality we already have the 'dont kiill nest server logic' if user is signing out and the websocket disconnects so what is cool is when i closed my laptop and opened it again, without it killing the nest server since i made it so it doesnt do that if im not logged in on my end for testing Kulveer Virk • can we have a call? You • it re-established the websocket connection yes can i skip stand up tomorrow or give my update and go focus tomorrow ill knock out the crashing stuff have a good eevening