HttpParseHeader)(HTTP parse header failed) when querying /api
Closed this issue · 2 comments
Describe the bug
When querying /api/v1/streams/
, the SRS log shows errors. This might be purely cosmetic, but I have no idea if this affects SRS's performance in any way.
Version
SRS Docker SRS/6.0.158(Hang), MIT
To Reproduce
Query /api/v1/streams/
(in this case this is done via XHR from a webpage)
Expected behavior
No errors in logs
Additional context
srs | [2024-12-03 12:50:32.703][INFO][1][412833qy] HTTP #0 172.19.0.1:52682 GET http://127.0.0.1:1985/api/v1/streams/, content-length=-1
srs | [2024-12-03 12:50:32.704][INFO][1][412833qy] TCP: before dispose resource(HttpConn)(0x60d0000002b0), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:32.704][INFO][1][412833qy] client finished.
srs | [2024-12-03 12:50:32.704][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:32.704][INFO][1][412833qy] TCP: disposing #0 resource(HttpConn)(0x60d0000002b0), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:32.717][INFO][1][52564q64] TCP: before dispose resource(HttpConn)(0x60d000000520), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:32.718][ERROR][1][52564q64][11] serve error code=3009(HttpParseHeader)(HTTP parse header failed) : parse message : parse message : parse 8B, nparsed=0, err=16/HPE_INVALID_METHOD invalid HTTP method
srs | thread [1][52564q64]: process_requests() [./src/app/srs_app_http_conn.cpp:184][errno=11]
srs | thread [1][52564q64]: parse_message() [./src/protocol/srs_protocol_http_conn.cpp:103][errno=11]
srs | thread [1][52564q64]: parse_message_imp() [./src/protocol/srs_protocol_http_conn.cpp:135][errno=11](Resource temporarily unavailable)
srs | [2024-12-03 12:50:32.718][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:32.718][INFO][1][52564q64] TCP: disposing #0 resource(HttpConn)(0x60d000000520), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:35.673][INFO][1][f359n2h2] HTTP #0 172.19.0.1:52688 GET http://127.0.0.1:1985/api/v1/streams/, content-length=-1
srs | [2024-12-03 12:50:35.673][INFO][1][f359n2h2] TCP: before dispose resource(HttpConn)(0x60d0000006c0), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:35.673][INFO][1][f359n2h2] client finished.
srs | [2024-12-03 12:50:35.674][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:35.674][INFO][1][f359n2h2] TCP: disposing #0 resource(HttpConn)(0x60d0000006c0), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:36.213][INFO][1][93qd7wb0] TCP: before dispose resource(HttpConn)(0x60d000000930), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:36.213][ERROR][1][93qd7wb0][11] serve error code=3009(HttpParseHeader)(HTTP parse header failed) : parse message : parse message : parse 8B, nparsed=0, err=16/HPE_INVALID_METHOD invalid HTTP method
srs | thread [1][93qd7wb0]: process_requests() [./src/app/srs_app_http_conn.cpp:184][errno=11]
srs | thread [1][93qd7wb0]: parse_message() [./src/protocol/srs_protocol_http_conn.cpp:103][errno=11]
srs | thread [1][93qd7wb0]: parse_message_imp() [./src/protocol/srs_protocol_http_conn.cpp:135][errno=11](Resource temporarily unavailable)
srs | [2024-12-03 12:50:36.213][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:36.213][INFO][1][93qd7wb0] TCP: disposing #0 resource(HttpConn)(0x60d000000930), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:37.192][INFO][1][m6h34t56] Hybrid cpu=0.00%,35MB
srs | [2024-12-03 12:50:37.791][INFO][1][a9419274] TCP: before dispose resource(HttpConn)(0x60d000000ad0), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:37.792][ERROR][1][a9419274][11] serve error code=3009(HttpParseHeader)(HTTP parse header failed) : parse message : parse message : parse 8B, nparsed=0, err=16/HPE_INVALID_METHOD invalid HTTP method
srs | thread [1][a9419274]: process_requests() [./src/app/srs_app_http_conn.cpp:184][errno=11]
srs | thread [1][a9419274]: parse_message() [./src/protocol/srs_protocol_http_conn.cpp:103][errno=11]
srs | thread [1][a9419274]: parse_message_imp() [./src/protocol/srs_protocol_http_conn.cpp:135][errno=11](Resource temporarily unavailable)
srs | [2024-12-03 12:50:37.792][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:37.792][INFO][1][a9419274] TCP: disposing #0 resource(HttpConn)(0x60d000000ad0), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:38.703][INFO][1][figj8737] HTTP #0 172.19.0.1:37166 GET http://127.0.0.1:1985/api/v1/streams/, content-length=-1
srs | [2024-12-03 12:50:38.703][INFO][1][figj8737] TCP: before dispose resource(HttpConn)(0x60d000000c70), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:38.703][INFO][1][figj8737] client finished.
srs | [2024-12-03 12:50:38.703][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:38.703][INFO][1][figj8737] TCP: disposing #0 resource(HttpConn)(0x60d000000c70), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:41.668][INFO][1][uo6i1400] HTTP #0 172.19.0.1:37178 GET http://127.0.0.1:1985/api/v1/streams/, content-length=-1
srs | [2024-12-03 12:50:41.669][INFO][1][uo6i1400] TCP: before dispose resource(HttpConn)(0x60d000000ee0), conns=1, zombies=0, ign=0, inz=0, ind=0
srs | [2024-12-03 12:50:41.669][INFO][1][uo6i1400] client finished.
srs | [2024-12-03 12:50:41.669][INFO][1][3063e02b] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
srs | [2024-12-03 12:50:41.669][INFO][1][uo6i1400] TCP: disposing #0 resource(HttpConn)(0x60d000000ee0), conns=1, disposing=1, zombies=0
srs | [2024-12-03 12:50:42.193][INFO][1][m6h34t56] Hybrid cpu=0.00%,35MB
srs | [2024-12-03 12:50:43.406][INFO][1][76n08eg2] TCP: before dispose resource(HttpConn)(0x60d000001150), conns=1, zombies=0, ign=0, inz=0, ind=0
You must have sent an http request with an 8 bytes body, check your XHR
api, is the xhr.send()
method invoked with content.
srs/trunk/src/protocol/srs_protocol_http_conn.cpp
Lines 128 to 130 in 7951bf3
Or add logs between line 129 and 130 to check what the hell of your 8 bytes invalidate content are.
char buf[buffer->size()+1];
buf[buffer->size()] = '\0';
snprintf(buf, buffer->size(), "%s", buffer->bytes());
srs_warn("http parser buffer is %s", buf);
Found it, after inspecting the packets entering the SRS port 8080.
This was completely unrelated to my API calls - the port exposed for SRS 8080 was 18080 - the default Monero node port. Someone was trying to query the exposed endpoint as a Monero node.
Sorry for bothering you with this and thank you for your time!