bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.51k stars 1.58k forks source link

Is there some method to distinguish network error or server reject error #1970

Open ggslayer opened 1 year ago

ggslayer commented 1 year ago

Hi, I'm using ffmpegrecorder to make rtmp push , when something wrong, I can get error message from start/record method, because I want to do more retry times to half an hour when network is error, and only 10 seconds when server reject. Is there some method can I get the error reason?

I got the error message from exception, include the socket error -32/-104/-110/... error code, As I know: -110/-111 means connect failed/ read/write timeout.
-104 is reset by server other code I'm not sure.

but the code, I can't get it easily, must parse from the exception string.

Is there some advice about my propose? thank you !

saudet commented 1 year ago

We could propagate the error code in the exception. It should be easy to add. Could you give it a try yourself and open a pull request?

ggslayer commented 1 year ago

After some test, I think the socket error can't distinguish the reason strictly, I want follow a simple stragy: consider network error when start method exception occurred, consider server reject when record method exception occurred. thank you !