nodemcu connection problem with firebase

Hi I’m working on a home automation project by controlling relays by mobile app and a nodemcu using firebase the code works correctly and i can control the relays but after few minutes the nodemcu failed to connect to firebase again …i tried to make it reconnect but i failed so i tried the reset button on the nodemcu then it works again correctly so every time it works for few minutes then disconnect from firebase then i reset then it reconnect and works normally for mintue then disconnect so i tried ESP.reset() if the firebas.connect failed then it works good but i don’t want to reset my nodemcu every time it disconnect from firebase !!! any one have a solution please