chriswiggins / rtsp-streaming-server

Lightweight RTSP/RTP streaming media server written in Javascript
GNU General Public License v3.0
106 stars 21 forks source link

Headers already sent? #1

Closed brennongs closed 5 years ago

brennongs commented 6 years ago

Hello, I'm running into trouble displaying my stream in VLC using your server, any ideas? I've pasted the code below, it seems like I am able to mount the stream correctly, but then when VLC sends the request it hangs. Any help would be appreciated. See below:

2018-03-30T19:14:25.822Z - info: RTSP server is running on port: 5554
2018-03-30T19:14:25.825Z - info: RTSP client server is running on port: 6554
2018-03-30T19:14:31.646Z - info: Set up mount at /2
2018-03-30T19:14:31.649Z - info: Setting up stream (0) on path /2
2018-03-30T19:14:31.653Z - info: Setting up stream (1) on path /2
2018-03-30T19:14:31.656Z - info: Listener for Stream(0) on path /2 on port 10000 successful
2018-03-30T19:14:31.656Z - info: Listener for Stream(0) on path /2 on port 10001 successful
2018-03-30T19:14:31.657Z - info: Listener for Stream(1) on path /2 on port 10002 successful
2018-03-30T19:14:31.657Z - info: Listener for Stream(1) on path /2 on port 10003 successful
/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-stream/lib/outgoing-message.js:47
  if (this.headersSent) throw new Error('Headers already sent!')
                        ^

Error: Headers already sent!
    at module.exports.OutgoingMessage.setHeader (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-stream/lib/outgoing-message.js:47:31)
    at ClientServer.describeRequest (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-streaming-server/lib/ClientServer.js:59:7)
    at Server.ClientServer.server.Rtsp.createServer (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-streaming-server/lib/ClientServer.js:16:18)
    at Server.emit (events.js:127:13)
    at module.exports.<anonymous> (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-server/index.js:48:14)
    at module.exports.emit (events.js:127:13)
    at module.exports.Decoder._writeHead (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-stream/decoder.js:77:30)
    at module.exports.Decoder._writeOffset (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-stream/decoder.js:37:21)
    at module.exports.Decoder._write (/Users/brennon/Codes/work/rtsp-mock/node_modules/rtsp-stream/decoder.js:27:8)
    at doWrite (/Users/brennon/Codes/work/rtsp-mock/node_modules/readable-stream/lib/_stream_writable.js:418:64)
[nodemon] app crashed - waiting for file changes before starting...
mbullock976 commented 6 years ago

Hi @brennongs, Did you manage to resolve this issue with vlc playback at all?

reedog117 commented 6 years ago

I'm also having this issue. Using Larix Broadcaster on both Android and iOS to attempt to send an HEVC RTSP stream to the server. Here's my log.

root@ubuntu:~/node-rtsp-test# node server.js 
2018-08-07T06:24:49.471Z - info: RTSP server is running on port: 5554
2018-08-07T06:24:49.477Z - info: RTSP client server is running on port: 6554
2018-08-07T06:24:53.002Z - info: Set up mount at /oneplus
2018-08-07T06:24:53.074Z - info: Setting up stream (0) on path /oneplus
/root/node-rtsp-test/node_modules/rtsp-stream/lib/outgoing-message.js:47
  if (this.headersSent) throw new Error('Headers already sent!')
                        ^

Error: Headers already sent!
    at module.exports.OutgoingMessage.setHeader (/root/node-rtsp-test/node_modules/rtsp-stream/lib/outgoing-message.js:47:31)
    at Server.setupRequest (/root/node-rtsp-test/node_modules/rtsp-streaming-server/lib/Server.js:76:7)
    at Server.server.Rtsp.createServer (/root/node-rtsp-test/node_modules/rtsp-streaming-server/lib/Server.js:16:18)
    at emitTwo (events.js:126:13)
    at Server.emit (events.js:214:7)
    at module.exports.<anonymous> (/root/node-rtsp-test/node_modules/rtsp-server/index.js:48:14)
    at emitOne (events.js:116:13)
    at module.exports.emit (events.js:211:7)
    at module.exports.Decoder._writeHead (/root/node-rtsp-test/node_modules/rtsp-stream/decoder.js:77:30)
    at module.exports.Decoder._writeOffset (/root/node-rtsp-test/node_modules/rtsp-stream/decoder.js:37:21)
cdebost commented 5 years ago

This issue is probably fixed by #5. The describe/setup handlers allowed execution to continue down the success path after the response was sent with an error code.

@brennongs In your case, DESCRIBE wanted to return a 404 because it could not find a mount for the url your client tried. @reedog117 In your case, SETUP wanted to return a 504 because your client requested TCP, which this project doesn't support.

Either way, I'm having another issue with VLC playback now: #4

chriswiggins commented 5 years ago

This should be resolved now - please re-open if it isn't!