ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.79k stars 5.28k forks source link

When using HTTP GET to access the WHIP API, the error codes are not accurate. #3838

Closed winlinvip closed 3 months ago

winlinvip commented 8 months ago

Describe the bug Normally, users should access the WHIP API using HTTP POST. But sometimes, users might habitually paste the WHIP API into the browser to access it. In this case, the error logs from SRS are not very clear, and there isn't a clear error response either.

Version SRS 5.0 and 6.0

To Reproduce Steps to reproduce the behavior:

  1. Run SRS by ./objs/srs -c conf/console.conf
  2. Use curl to request WHIP API: curl -v 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream'
  3. The response is not clear:
    curl -v 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream'
    *   Trying 127.0.0.1:1985...
    * Connected to localhost (127.0.0.1) port 1985 (#0)
    > GET /rtc/v1/whip/?app=live&stream=livestream HTTP/1.1
    > Host: localhost:1985
    > User-Agent: curl/8.1.2
    > Accept: */*
    > 
    * Empty reply from server
    * Closing connection 0
    curl: (52) Empty reply from server
  4. SRS error is not clear:
    [2023-10-16 08:56:29.205][INFO][50045][1np2j16n] HTTP #0 127.0.0.1:58926 GET http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream, content-length=-1
    [2023-10-16 08:56:29.206][INFO][50045][1np2j16n] RTC whip publish /live/livestream, clientip=127.0.0.1, app=live, stream=livestream, offer=0B, eip=, codec=, srtp=, dtls=, ufrag=, pwd=, param=app=live&stream=livestream
    [2023-10-16 08:56:29.206][INFO][50045][1np2j16n] TCP: before dispose resource(HttpConn)(0x607000003f20), conns=1, zombies=0, ign=0, inz=0, ind=0
    [2023-10-16 08:56:29.207][ERROR][50045][1np2j16n][35] serve error code=5018(RtcSdpNegotiate)(RTC do SDP negotiate failed) : process request=0 : cors serve : serve http : serve : serve : remote sdp check failed : now only support BUNDLE, group policy=
    thread [50045][1np2j16n]: process_requests() [./src/app/srs_app_http_conn.cpp:209][errno=35]
    thread [50045][1np2j16n]: process_request() [./src/app/srs_app_http_conn.cpp:236][errno=35]
    thread [50045][1np2j16n]: serve_http() [./src/protocol/srs_protocol_http_stack.cpp:768][errno=35]
    thread [50045][1np2j16n]: serve_http() [./src/app/srs_app_rtc_api.cpp:628][errno=35]
    thread [50045][1np2j16n]: do_serve_http() [./src/app/srs_app_rtc_api.cpp:739][errno=35]
    thread [50045][1np2j16n]: serve_http() [./src/app/srs_app_rtc_api.cpp:470][errno=35]
    thread [50045][1np2j16n]: check_remote_sdp() [./src/app/srs_app_rtc_api.cpp:529][errno=35](Resource temporarily unavailable)

Expected behavior SRS should use more specific error codes, instead of the current now only support BUNDLE. SRS should return error codes and messages in the HTTP Response.

Additional context Note: Previously, no error response was returned, primarily for simplicity. Also, when returning a response, sensitive information needs to be avoided. There were many factors to consider, so detailed error messages were not returned.

TRANS_BY_GPT4

winlinvip commented 3 months ago

Fixed.