fix issue with socket communication not working on first page load