@yusure I have fixed the issue. I tested like you said on 4G mobile hotspot and it worked flawlessly. Then based on this post Device connection issue caused by DNS resolution failure I changed my DNS settings in my router settings to the Google DNS public IPs and it works fine now.
Thanks again for the help.