Problems with automatic reconnection

Javier1000

New Member
Hello!

I have a 24/7 streaming of a P2P camera via RTSP through a third server that gives me that RTSP connection. The server changes IP every day at 3 am due to the configuration of my ISP that does not provide static IPs. It is always at that time that the streaming connection is cut off and the OBS software is unable to connect. I have tested with OBS version 27.2.1 and 27.0.0 and with both the same thing happens. It happens both when the source is multimedia and VLC. It is not a problem of the server because with a small Python script (independent to the OBS) I get the automatic reconnection at that time without problem, but the OBS does not get it.

The OBS log does not show the disconnection, the first records that appear are the following. There is nothing in Error reports. I have set up 90 retries at 30 second intervals.
03:39:24.345: WriteN, RTMP send error 10054 (4097 bytes)
03:39:24.345: WriteN, RTMP send error 10054 (59 bytes)
03:39:24.346: WriteN, RTMP send error 10038 (42 bytes)
03:39:24.346: [rtmp stream: 'simple_stream'] Disconnected from rtmps://a.rtmps.youtube.com
03:39:24.346: Output 'simple_stream': Reconnecting in 30 seconds..
03:39:24.346: [rtmp stream: 'simple_stream'] Freeing 839 remaining packets
03:39:30.298: MP: av_read_frame failed: Bad file descriptor (-9)
03:39:52.777: MP: av_read_frame failed: Bad file descriptor (-9)
03:39:54.348: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmps://a.rtmps.youtube.com...
03:39:54.497: [rtmp stream: 'simple_stream'] Interface: Realtek 8822CE Wireless LAN 802.11ac PCI-E NIC (802.11, 585 mbps)
03:39:55.622: [rtmp stream: 'simple_stream'] Connection to rtmps://a.rtmps.youtube successful
03:40:14.980: MP: av_read_frame failed: Bad file descriptor (-9)
03:40:37.610: MP: av_read_frame failed: Bad file descriptor (-9)
03:40:59.311: MP: av_read_frame failed: Bad file descriptor (-9)

This is the standalone Python code where I have seen that the reconnection is carried out without a problem:
import cv2
import time
import datetime
while True:
try:
rstp = 'rtsp://MyRSTP'
cap = cv2.VideoCapture(rstp)
while True:
ret, frame = cap.read()
frame_s = cv2.resize(frame, (672, 378))
cv2.imshow(rstp,frame_s)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
except Exception as e:
date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
cad = "{0}: {1}".format(date, e)
print(cad)
try:
cap.release()
cv2.destroyAllWindows()
except Exception as e:
date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
cad = "{0}: {1}".format(date, e)
print(cad)
time.sleep(180)

The Python log when the connection fails:
2022-02-27 03:00:32: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

Could someone help me? Thank you very much in advance!!
 
Top