VideoCapture can't open RTSP stream [FIXED]

What I have found is the following:
It can happen because the cap.read fuction returns a false, thus the frame is empty.
Possible solutions are to cover it by an if statement

if ret false:
cap.release()
cap = cv2.VideoCapture(‘IP camera’)
ret, frame = cap.read()

This solution doesn’t work because ret is always false.
this keeps me in an endless loop