Thank you for the reply and my apologies for the delayed response, I am very glad that you want to help.
I discussed the option of opening the web socket connection before calling load() with my project members but this doesn't seem for the solution we have been looking for.
After brainstorming about what should work, the perfect solution would be that connection with the web socket server is called after load(), so we can keep this connection to the web socket server open. Sending the username to the server won't be a one-time thing and even if we manage to create a connection before load(), send the username to the server, close this connection and create a connection after load(), the microcontroller would connect to a different web socket.
So we are searching for a way to call the connection to the web socket server after load() and keep this same connection open . I tried out to send some simple console logs after load() to see if the microcontroller does anything after it reboots and that seems to work, but it still won't execute the ws connection code so we are pretty much stuck now.
Once again thank you for the reply and i hope you have a solution for this.