@Ashwin Kumar Samal , I did stream with the following code in my environment where I see there is no issue with the code. Also, there should not be any barriers from the OS side. I suggest you check these two,
- You should use the Public IP of your router while connecting to RSTP URL.
- Make sure you open the 554 ports on your VM NSG rules. (NSG's are Firewall rules that will by default restrict I/B and O/B traffic to a VM).
This should solve your issue.
----------
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.