Repository navigation
RTSP DESCRIBE 401 when both BASIC and DIGEST auth is offered. #9800
Copy link
Copy link
Closed
Labels
Description
When trying to play a HikVision IP Camera I get DESCRIBE 401 error.
The URL looks like this: rtsp://USER:PASS@172.30.34.12:554/Streaming/channels/102
Formats ( based on VLC's media information ) : H264 - MPEG-4 AVC (part 10) (h264)
Changing WWW_AUTHENTICATION_HEADER_BASIC_PATTERN to match WWW-Authenticate: Basic realm="IP Camera(C1214)" ( mentioned here ) didn't help, although I think it is also an issue because it currently doesn't recognize capital letters and numbers.
Auth
2021-12-21 12:05:35.895 10631-10956/com.dotlab.pierre.digitalhive D/RtspClient: RTSP/1.0 200 OK
CSeq: 0
Public: OPTIONS, DESCRIBE, PLAY, PAUSE, SETUP, TEARDOWN, SET_PARAMETER, GET_PARAMETER
Date: Tue, Dec 21 2021 12:08:36 GMT
2021-12-21 12:05:35.907 10631-10956/com.dotlab.pierre.digitalhive D/RtspClient: DESCRIBE rtsp://172.30.34.12:554/Streaming/channels/102 RTSP/1.0
User-Agent: ExoPlayerLib/2.16.1
CSeq: 1
2021-12-21 12:05:35.929 10631-10956/com.dotlab.pierre.digitalhive D/RtspClient: RTSP/1.0 401 Unauthorized
CSeq: 1
WWW-Authenticate: Digest realm="IP Camera(C1214)", nonce="0191a41d87c28cd52b3e9c8adc99291c", stale="FALSE"
WWW-Authenticate: Basic realm="IP Camera(C1214)"
Date: Tue, Dec 21 2021 12:08:36 GMT
2021-12-21 12:05:35.937 10631-10956/com.dotlab.pierre.digitalhive D/RTSPClient: parseWwwAuthenticateHeader: BASIC
2021-12-21 12:05:35.942 10631-10956/com.dotlab.pierre.digitalhive D/RtspClient: DESCRIBE rtsp://172.30.34.12:554/Streaming/channels/102 RTSP/1.0
User-Agent: ExoPlayerLib/2.16.1
CSeq: 2
Authorization: YWRtaW46ZGlnaXRhTGhpdkUh
2021-12-21 12:05:35.957 10631-10956/com.dotlab.pierre.digitalhive D/RtspClient: RTSP/1.0 401 Unauthorized
CSeq: 2
WWW-Authenticate: Digest realm="IP Camera(C1214)", nonce="22bb4bccbd3fdd372b71c3447fc5a714", stale="FALSE"
WWW-Authenticate: Basic realm="IP Camera(C1214)"
Date: Tue, Dec 21 2021 12:08:36 GMT
Error
021-12-21 12:05:35.976 10631-10956/com.dotlab.pierre.digitalhive E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:628)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:246)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.io.IOException: DESCRIBE 401
at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:564)
at com.google.android.exoplayer2.source.rtsp.RtspClient.dispatchRtspError(RtspClient.java:305)
at com.google.android.exoplayer2.source.rtsp.RtspClient.access$600(RtspClient.java:73)
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:561)
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:494)
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$RtspClient$MessageListener(RtspClient.java:487)
at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspClient$MessageListener$dJPB0r-FyeWq7xUwLx0FyxTnUk0.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: DESCRIBE 401
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:563)
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:494)
at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$RtspClient$MessageListener(RtspClient.java:487)
at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspClient$MessageListener$dJPB0r-FyeWq7xUwLx0FyxTnUk0.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.os.HandlerThread.run(HandlerThread.java:67)
Versions
- ExoPlayer version number: 2.16.1
- Android version: 11
- Android device: Samsung Galaxy Tab A
Reactions are currently unavailable
Activity
claincly commentedon Dec 21, 2021
The error happened because the server doesn't recognize the provided authentication info (
YWRtaW46ZGlnaXRhTGhpdkUh). To isolate the issue, can you trybase64_encode("<username>:<password>")and see if it matches
YWRtaW46ZGlnaXRhTGhpdkUh?As an aside, the current regex does match
Basic realm="IP Camera(C1214)"claincly commentedon Dec 21, 2021
My guess is, although your server provides BASIC auth scheme, it does not actually supports it. The server supports digest auth only.
DanijelBojcic commentedon Dec 21, 2021
I can confirm that it matches
YWRtaW46ZGlnaXRhTGhpdkUhIf the problem is on the server how can VLC play it?
claincly commentedon Dec 22, 2021
It would be helpful if you wireshark VLC and confirm if it uses digest instead. If it is, it's a sign for us to add "force using digest auth"
DanijelBojcic commentedon Dec 23, 2021
I was able to debug it. Here is the flow:
It seems you've guessed rigth. How can I force exoplayer to use DIGEST auth instead until you fix it?
claincly commentedon Dec 23, 2021
You can patch
RtspClientwith the following code to prefer DIGEST:DanijelBojcic commentedon Dec 27, 2021
I have tried the patch, it forces the digest auth, but after the authentication I get the same error as before.
EDIT: I've just realized that it's not the same error, it's now SETUP 401. Should I open another issue for this?
These are the logs I get:
claincly commentedon Dec 29, 2021
Can you try building
RtspMediaSourcewithforceUseRtpTcpset to true?DanijelBojcic commentedon Jan 3, 2022
Thanks @claincly
It's working with the patch and the
forceUseRtpTcpset to true.[-]RTSP DESCRIBE 401 [HikVision][/-][+]RTSP DESCRIBE 401 when both BASIC and DIGEST auth is offered.[/+]claincly commentedon Jan 4, 2022
A note on why
forceUseRtpTcpworked:When ExoPlayer retries for using TCP, the flow is like
The server does not accept initiating authentication when performing SETUP, but ExoPlayer's TCP retrying logic starts with SETUP.
forceUseRtpTcpthough, eliminated the need to retry and thus will work.In VLC's case, the retry logic starts the entire RTSP exchange (from OPTIONS, to DESCRIBE, SETUP, PLAY) again.
Prefers DIGEST when RTSP servers sends both BASIC and DIGEST auth info.
Prefers DIGEST when RTSP servers sends both BASIC and DIGEST auth info.