Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBS - Failed to connect to server when running in docker #403

Open
benny1611 opened this issue Jan 31, 2021 · 21 comments
Open

OBS - Failed to connect to server when running in docker #403

benny1611 opened this issue Jan 31, 2021 · 21 comments

Comments

@benny1611
Copy link

Hello,

I've been trying for a couple of hours to set up nodetube on my local machine (just to test it out) via docker-compose. I've added an extra port for the nodetube container "1935:1935" because I care more about the live streaming aspect of this project, Unfortunately, I couldn't connect to the live-stream via OBS. Every time I try to start the stream I get the message "Failed to connect to server".

I went to settings and made sure that I have the right link:

Server:  rtmp://127.0.0.1:1935/live
Stream Key:  /test?key=<my key>

I've also looked in the OBS logs and saw this:

14:33:55.946: ------------------------------------------------
14:33:58.007: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://127.0.0.1:1935/live...
14:33:58.008: [rtmp stream: 'simple_stream'] Interface: Software Loopback Interface 1 (type 24, 1073 mbps)
14:33:58.013: RTMPSockBuf_Fill, remote host closed connection
14:33:58.013: RTMP_Connect1, handshake failed.
14:33:58.013: [rtmp stream: 'simple_stream'] Connection to rtmp://127.0.0.1:1935/live failed: -2
14:33:58.022: ==== Streaming Stop ================================================

I couldn't see anything in the nodetube container logs (nothing showed up other than the "normal" logs, no errors or warnings).

Could you point out what I'm doing wrong? Thank you very much!

Details about my system:
Windows 10 Pro
Server: Docker Engine - Community
Engine:
Version: 20.10.2

@l1ghtsword
Copy link

l1ghtsword commented Feb 1, 2021

I looked into this and am stumped myself as well...
I cant seem to get this functionality running it from Docker or locally with the pre-reqs installed and running...

For whatever reason it just seems to be refusing to connect to the server.
The closest I got was with docker adding - "1935:1935" to the ports section of node. it seems to be timing out with lack of response... (that should work)

I'm poking around the backend to trace out where this listener should be started and why its not responding to RTMP traffic.

@l1ghtsword
Copy link

l1ghtsword commented Feb 1, 2021

EDIT: Okay I think I see what's happening here... Ngnix has configuration files written to work with Nodetube, but is not actually installed or setup with the image... IE we are missing the actual server to respond to the request.
going to tinker with it and get a write up going...

In the build directory, see docs/ngnix/ in the project directory for what appears to be a few variations of a config. I have a similar setup so its only a mater of installing Ngnix and copying a functional config to it...

furthermore, there is no mention of Ngnix in the docker-compose, but that's an easy fix.

@benny1611
Copy link
Author

Do you think you can fix it? It would be nice to have a working docker version. Just docker-compose up -d and you have a whole video/streaming platform up and running.

@l1ghtsword
Copy link

l1ghtsword commented Feb 1, 2021

I plan on it, its a little more complicated then adding a ngnix-rtmp docker container because nodetube expects the stream to be a readable file being created in uploads... Ill see what i can do to remedy that design.

EDIT: very incorrect. the content from HLS is forwarded to the nodetube service directly and authenticated there. recordings is its own directory and separate from uploads entirely.

@l1ghtsword
Copy link

l1ghtsword commented Feb 2, 2021

Okay.
Got to the bottom of it, will submit a PR when I have a docker and non-docker build...

For docker, you can get the source from my fork for now and test it. https://github.com/l1ghtsword/nodetube.git

There was some misunderstanding of what was going on, apologies for the delay, I had to catch up on some reading...
If you care about the details, Nginx is just a side service that receives the request, and forwards it to Nodetube for authentication and publishing. there are still some changes I would like to implement with this, like re-rendering for example. but I wanted to get a working build out asap.

I was able to have this working in my docker build, should just be a matter of doing a docker-compose up on your side once you DL the source above. I made the config for Nginx read from local every time so it can be edited easily. I turned recording to ./recording off by default. Its heavily commented so feel free to tweak it as desired. just don't break it ;)

@l1ghtsword
Copy link

^ ignore that, PR'ed the wrong repo :x

@benny1611
Copy link
Author

Ok, so first, I'm sorry for the late reply, I've been really busy these days. I've finally managed to clone your repository and try it out on my machine (Windows). The problem with "failed to connect to server" is gone, it says that it's connected and also streaming, BUT it's not streaming... I've waited for longer than 10 seconds and still nothing, then I looked into the logs of the nodetube container and saw some 404 errors there whenever I've tried to connect to the stream. I don't know what the problem is this time (or if it's on my machine). To be sure I've also pulled up the good ol' WireShark and did a scan of the 1935 TCP port. You can download the PCAP file here if you want to check it out too.

Steps to reproduce:

  1. docker-compose up -d
  2. I've made an account "test" with the password set to "test"
  3. Started live streaming with OBS

Logs from nodetube container:

> [email protected] start /app
> node --max-old-space-size=4096 app.js
BOOTING APP...
PLUS ENABLED: false
NODE_ENV: development
RUNNING WITH THIS MANY PROCESSES: 1
SAVE AND SERVE FILES DIRECTORY: ./uploads
THE MOST CONTROVERSIAL UPLOAD RATING ALLOWED ON THIS INSTANCE IS: SFW
CACHING IS ON
CACHING IS RUNNING AGAINST: mongodb://nodetube-mongo:27017/nodetube
CONNECTING TO REDIS, HOST: redis, PORT: 6379
CACHE RECENT INTERVAL IN MINUTES: 1
CACHE POPULAR, DAILY STATS AND INDEXES INTERVAL IN MINUTES: 5
(node:18) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6
API key does not start with "SG.".
CONNECTING TO REDIS, HOST: redis, PORT: 6379
ffmpeg path: /app/node_modules/@ffmpeg-installer/linux-x64/ffmpeg
youtube-dl binary path: /app/node_modules/youtube-dl/bin/youtube-dl
DATABASE: mongodb://nodetube-mongo:27017/nodetube
CONNECTING TO REDIS, HOST: redis, PORT: 6379
UPLOADS ON: true
UPLOAD SERVER: /uploads
DOMAIN NAME AND TLD: https://nodetube.live
FRONTEND SERVER:
CACHING LOGS WILL NOT COME THROUGH
CONNECTED TO DATABASE AT: mongodb://nodetube-mongo:27017/nodetube
RUNNING AS FRONTEND
(node:25) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6
NodeTube can be accessed on your local network at 172.18.0.5:3000
Websockets server started over http on port 8443
✓ App is running at http://localhost:3000 in development mode
Press CTRL-C to stop
Access NodeTube on the public web via https://54f375c220a3.ngrok.io. This link will be changed if you restart the app, to
use Ngrok with a permanent subdomain please purchase a token and update the settings in .env.private (see runNgrok function in app.js)
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/ header: undefined
GET / 200 1166.902 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/login header: http://localhost:49161/
GET /login 200 529.979 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/signup header: http://localhost:49161/login
GET /signup 200 382.480 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/signup header: http://localhost:49161/signup
test <--- inputted channelUrl forundefined
(node:25) DeprecationWarning: req.validationErrors() may be removed in a future version. Use req.getValidationResult() instead.
(node:25) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use Collection.countDocuments or Collection.estimatedDocumentCount instead
null
POST /signup 302 308.320 ms - 60
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/account header: http://localhost:49161/signup
GET /account 200 463.176 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/account/profile header: http://localhost:49161/account
UPDATING PROFILE FOR test
FILE EXTENSION:
{ privs:
{ autoVisibleUpload: false,
mirrorFunctionality: false,
unlistedUpload: true,
privateUpload: true,
youtubeBackup: false,
uploadSize: 2000,
safeForWorkUpload: true,
livestreaming: true,
importer: true },
userSettings: { mirrorOn: false, backupOn: false, monetizationOn: false },
userData: { ips: [] },
socialMedia: {},
emailConfirmed: false,
role: 'admin',
verified: false,
usedUploadServers: [],
receivedSubscriptions: [],
subscriptions: [],
tokens: [],
uploads: [],
comments: [],
filter: 'allAges',
plan: 'plus',
unseenSubscriptionUploads: 0,
curated: false,
credit: 0,
receivedCredit: 0,
defaultQuality: 'low',
blockedUsers: [],
pushNotificationEndpoints: [],
_id: 601af55a262c9c0019d2a37f,
email: '0.77345471427249280.6343746016769172',
password:
'$2a$10$ybUJrmM.CvuWWuqPSh1Upumzrk81kUTwKLwobKnlIgG0jXgWD0Q4.',
channelUrl: 'test',
createdAt: 2021-02-03T19:11:22.291Z,
updatedAt: 2021-02-03T19:11:22.615Z,
__v: 0,
uploadToken: 'Cp0Pk88bbvAnVSqSeKQJExr3Z',
channelName: 'test',
channelDescription: 'test' }
POST /account/profile 200 39.072 ms - 7
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/account?update=success header: http://localhost:49161/account
GET /account?update=success 200 482.061 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/account/livestreaming header: http://localhost:49161/account?update=success
::ffff:172.18.0.1 49166 ::ffff:172.18.0.5 3000
::ffff:172.18.0.1
3000
/account/livestreaming
rtmp://172.18.0.5:1935/live/test?key=Cp0Pk88bbvAnVSqSeKQJExr3Z http://localhost:49161/live/test
GET /account/livestreaming 200 318.931 ms - -
ip: ::ffff:172.18.0.3 req url: http://nodetube/livestream/on-live-auth header: undefined
{ app: 'live',
flashver: 'FMLE/3.0 (compatible; FMSc/1.0)',
swfurl: 'rtmp://127.0.0.1:1935/live',
tcurl: 'rtmp://127.0.0.1:1935/live',
pageurl: '',
addr: '172.18.0.1',
clientid: '1',
call: 'publish',
name: '/test',
type: 'live',
key: 'Cp0Pk88bbvAnVSqSeKQJExr3Z' }
Cp0Pk88bbvAnVSqSeKQJExr3Z
authentication passed
found user: test
Access the livestream at /live/test
POST /livestream/on-live-auth 200 23.721 ms - 7
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/live/test header: http://localhost:49161/account/livestreaming
test
GET /live/test 200 4270.033 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 404 3913.102 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/live/test header: http://localhost:49161/account/livestreaming
test
GET /live/test 200 965.145 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 404 967.588 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/live/test header: http://localhost:49161/account/livestreaming
test
GET /live/test 200 930.659 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 404 1600.369 ms - -
ip: ::ffff:172.18.0.3 req url: http://nodetube/livestream/on-live-done header: undefined
{ app: 'live',
flashver: 'FMLE/3.0 (compatible; FMSc/1.0)',
swfurl: 'rtmp://127.0.0.1:1935/live',
tcurl: 'rtmp://127.0.0.1:1935/live',
pageurl: '',
addr: '172.18.0.1',
clientid: '1',
call: 'publish_done',
name: '/test',
key: 'Cp0Pk88bbvAnVSqSeKQJExr3Z' }
POST /livestream/on-live-done 200 47.194 ms - 4
ip: ::ffff:172.18.0.3 req url: http://nodetube/livestream/on-live-auth header: undefined
{ app: 'live',
flashver: 'FMLE/3.0 (compatible; FMSc/1.0)',
swfurl: 'rtmp://127.0.0.1:1935/live',
tcurl: 'rtmp://127.0.0.1:1935/live',
pageurl: '',
addr: '172.18.0.1',
clientid: '4',
call: 'publish',
name: '/test',


type: 'live',
key: 'Cp0Pk88bbvAnVSqSeKQJExr3Z' }
Cp0Pk88bbvAnVSqSeKQJExr3Z
authentication passed
found user: test
Access the livestream at /live/test
POST /livestream/on-live-auth 200 28.411 ms - 7
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/live/test header: http://localhost:49161/account/livestreaming
test
GET /live/test 200 1984.284 ms - -
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 404 2837.900 ms - -
ip: ::ffff:172.18.0.3 req url: http://nodetube/livestream/on-live-done header: undefined
{ app: 'live',
flashver: 'FMLE/3.0 (compatible; FMSc/1.0)',
swfurl: 'rtmp://127.0.0.1:1935/live',
tcurl: 'rtmp://127.0.0.1:1935/live',
pageurl: '',
addr: '172.18.0.1',
clientid: '4',
call: 'publish_done',
name: '/test',
key: 'Cp0Pk88bbvAnVSqSeKQJExr3Z' }
POST /livestream/on-live-done 200 14.907 ms - 4
ip: ::ffff:172.18.0.1 req url: http://localhost:49161/ header: undefined
GET / 200 652.027 ms - -

@l1ghtsword
Copy link

Hmm, yeah I can see the authentication passed from that log, and it seems to exit as well.
The traffic from obs to nginx over 1935 is working, and the hls data is being forwarded to nodetube.
Do you get anything when you access the nodetube live page?
http://localhost:49161/live/test ???

Im not able to reproduce that on my end. Though, i am using my local ip and added a record to my host file for my dev domain in the env files. Have you configured it all yet?

@l1ghtsword
Copy link

l1ghtsword commented Feb 3, 2021

Actually i can already see you didn't, or at least not enabling the live stream routes. RUNNING AS FRONTEND tells me its running the main routes but RUNNING AS LIVESTREAM APP or something of the sort would tell me you set that to true in your env.settings.

Some assembly required*
change env.settings
LIVESTREAM_APP=false to true (LIVESTREAM_APP=true)
And see if that alone is enough

@benny1611
Copy link
Author

Ohh, ok I'll try that. Where can I find env.settings?

@l1ghtsword
Copy link

l1ghtsword commented Feb 3, 2021

so this is a little quirky, the dockerization of this app is not ideal (hence why i'm still working on it)...
The env.settings file is in the project source root, however... You will need to blow away the "nodetube" container and the "nodetube", "bougyman/voidlinux" and "none" images then rebuild to edit them... not ideal - im putting together a more dev/ prod docker friendly environment.

@benny1611
Copy link
Author

Nvm, I've found it (typical me, first ask then look in the project...), anyway I've done what you've just said, but still no luck (I've changed the .env.settings.sample file tho then rebuild everything, I've also deleted the dangling images before building). I've got this in the logs now (302):

> [email protected] start /app
> node --max-old-space-size=4096 app.js
BOOTING APP...
PLUS ENABLED: false
NODE_ENV: development
RUNNING WITH THIS MANY PROCESSES: 1
SAVE AND SERVE FILES DIRECTORY: ./uploads
THE MOST CONTROVERSIAL UPLOAD RATING ALLOWED ON THIS INSTANCE IS: SFW
CACHING IS ON
CACHING IS RUNNING AGAINST: mongodb://nodetube-mongo:27017/nodetube
CONNECTING TO REDIS, HOST: redis, PORT: 6379
CACHE RECENT INTERVAL IN MINUTES: 1
CACHE POPULAR, DAILY STATS AND INDEXES INTERVAL IN MINUTES: 5
(node:17) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6
API key does not start with "SG.".
CONNECTING TO REDIS, HOST: redis, PORT: 6379
ffmpeg path: /app/node_modules/@ffmpeg-installer/linux-x64/ffmpeg
youtube-dl binary path: /app/node_modules/youtube-dl/bin/youtube-dl
DATABASE: mongodb://nodetube-mongo:27017/nodetube
CONNECTING TO REDIS, HOST: redis, PORT: 6379
UPLOADS ON: true
UPLOAD SERVER: /uploads
DOMAIN NAME AND TLD: https://nodetube.live
FRONTEND SERVER:
CACHING LOGS WILL NOT COME THROUGH
CONNECTED TO DATABASE AT: mongodb://nodetube-mongo:27017/nodetube
Running as livestream app
(node:24) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6
NodeTube can be accessed on your local network at 172.20.0.5:3000
Websockets server started over http on port 8443
✓ App is running at http://localhost:3000 in development mode
Press CTRL-C to stop
Access NodeTube on the public web via https://5a0a0278fb47.ngrok.io. This link will be changed if you restart the app, to
use Ngrok with a permanent subdomain please purchase a token and update the settings in .env.private (see runNgrok function in app.js)
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/ header: undefined
GET / 200 1249.868 ms - -
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/account header: http://localhost:49161/
GET /account 200 1712.559 ms - -
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/account/livestreaming header: http://localhost:49161/account
::ffff:172.20.0.1 47428 ::ffff:172.20.0.5 3000
::ffff:172.20.0.1
3000
/account/livestreaming
rtmp://172.20.0.5:1935/live/test?key=Cp0Pk88bbvAnVSqSeKQJExr3Z http://localhost:49161/live/test
GET /account/livestreaming 200 999.673 ms - -
ip: ::ffff:172.20.0.4 req url: http://nodetube/livestream/on-live-auth header: undefined
{ app: 'live',
flashver: 'FMLE/3.0 (compatible; FMSc/1.0)',
swfurl: 'rtmp://127.0.0.1:1935/live',
tcurl: 'rtmp://127.0.0.1:1935/live',
pageurl: '',
addr: '172.20.0.1',
clientid: '1',
call: 'publish',
name: '/test',
type: 'live',
key: 'Cp0Pk88bbvAnVSqSeKQJExr3Z' }
Cp0Pk88bbvAnVSqSeKQJExr3Z
authentication passed
found user: test
Access the livestream at /live/test
POST /livestream/on-live-auth 200 57.633 ms - 7
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/live/test header: http://localhost:49161/account/livestreaming
test
GET /live/test 200 3571.115 ms - -
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 302 238.003 ms - 61
ip: ::ffff:172.20.0.1 req url: http://localhost:49161/test.m3u8 header: http://localhost:49161/live/test
GET /test.m3u8 302 73.945 ms - 61

@l1ghtsword
Copy link

l1ghtsword commented Feb 3, 2021

Yeah I also came to that conclusion, just spun up the containers myself...
nope I'm wrong, it is adding the default sample files to the docker image, unedited...

Ill need to fix that as well. I was editing things manually in the container which is bad and i should know better. those changes wont be retained either...
Shouldn't be hard, 2 minutes...

@benny1611
Copy link
Author

Yeah, I've looked into the Dockerfile of the project, then I saw it immediately. I know how it is XD I work with docker almost every day.

@l1ghtsword
Copy link

maaaaaaaaan this is annoying, i had this working the other day, now it wont display anything...
Okay, leave it with me i need to figure out why its not publishing anything...

@l1ghtsword
Copy link

l1ghtsword commented Feb 3, 2021

Okay, cardinal sin number 2, I made a last minute change without testing it. apologies my guy...
the hls folder is being monitored by Nodetube directly, so it is a shared volume as well. I through it was forwarding the traffic however that does not appear to be the case...

Ill do more testing but this build /should/ work https://github.com/l1ghtsword/nodetube.git

tl:dr you only need to change the docker-compose and i think nginx.conf
tested it, it is working on my side...

@benny1611
Copy link
Author

Works like a charm, I still had to make some adjustments tho. The files .env.settings and .env.private couldn't be found so docker wouldn't start the container. I changed that to .env.settings.sample and .env.private.sample respectively in the volumes list of the node container then everything worked. I'll test it some more today and I'll let you know if I find something else. Thank you!

PS: I also have the modified .env.settings.sample with the variable LIVESTREAM_APP set to true

@l1ghtsword
Copy link

l1ghtsword commented Feb 4, 2021

You would need to run it once to have it copy them to the local directory for you. a word of caution, i would advise against changing the env.sample files and instead simply copy and paste them into the root directory and remove the ".sample" at the end.

That way you have a clean reffernce in the event something breaks due to a setting change.
Also, env.sample files are subject to change (and get overwritten) as they are template files observed by git. .gitignore only ignores non sample files with the expectation api keys or private settings are in there...

Glad to hear this issue is resolved though, thanks for confirming.

@benny1611
Copy link
Author

benny1611 commented Feb 4, 2021

New problem: I can't do anything other than seeing the "my account" page (click on the account icon top left then go to my account). If I try anything else I get redirected to something like this: https://https//nodetube.live/ and then the browser can't find an address for that (duh). This worked before the fix, but now it stopped working. I didn't know if I should start a separate issue or write it here since the PR hasn't been applied yet

EDIT: The main page works, but if I try to search for example or do anything other than "my account", it redirects me to that weird URL

@l1ghtsword
Copy link

That's an issue with lack of configuration not core functionality. for general questions not related to a specific software issue, you can ask them in the discord

Lets avoid adding out of scope issues to this issue #

@BassOfBass
Copy link
Collaborator

@benny1611
Yeah you should create a separate issue for that.
In regards to .env.settings.sample and .env.private.sample, it looks like docker runs npm install, which also runs a postinstall script copying contents of the those files to .env.settings and .env.private respectively, that's why it worked (even though it's not advisable to do so). Hope you didn't do any public commits after changing those files, otherwise all your private keys will be for everyone to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants