Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

apache - Cannot connect to remote rtmp server

I'm trying to build a private streaming server (RTMP/HLS) with Go. The basic concept is similar to Twitch. The user can live broadcast a video using OBS (and a unique key).

I came across a Go framework called Seal, which seems to do exactly what I wish. https://github.com/calabashdad/seal

However, OBS cannot connect to the remote server although Seal-framework says it's listing the streaming port (rtmp.myserver.com:1935).

OBS Streaming link:

rtmp://rtmp.myserver.com/live/test

Seal run log (./seal -c conf/seal.yaml):

2021/01/12 12:08:26.003814 seal.go:55: load conf file success, conf={System:{CPUNums:0} Rtmp:{Listen:1935 TimeOut:30 ChunkSize:60000 Atc:false AtcAuto:true TimeJitter:1 ConsumerQueueSize:5} Hls:{Enable:true HlsFragment:4 HlsWindow:20 HlsPath:/var/www/go_projects/src/seal/hls_files HttpListen:7001}}
2021/01/12 12:08:26.003961 seal.go:60: app run on auto cpu nums= 2
2021/01/12 12:08:26.004415 rtmp_server.go:29: rtmp server start liste at :1935
2021/01/12 12:08:26.004010 hls_server.go:34: start hls server, listen at : 7001

Apache VirtualHost config:

<VirtualHost *:80>
ProxyPreserveHost On
    ProxyRequests Off

ServerName rtmp.myserver.com
ServerAlias rtmp.myserver.com
ServerAdmin webmaster@rtmp.myserver.com
DocumentRoot /var/www/go_projects/src/seal

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / rtmp://rtmp.myserver.com:1935/
ProxyPassReverse / rtmp://rtmp.myserver.com:1935/

<Directory /var/www/go_projects/src/seal>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>

OBS Error: Failed to connect to the server. Connection timed out.

I even tried to replace RTMP with HTTP in Apache Conf file and it seems that a connection could be established, but there was a Timeout error.

2021/01/12 13:36:23.221275 rtmp_server.go:36: one rtmp connection come in, remote= xx.xx.xx.105:44720
2021/01/12 13:36:53.222093 cycle.go:79: rtmp handshake failed.err= read tcp xx.xx.xx.105:1935->xx.xx.xx.105:44720: i/o timeout

Whereas xx.xx.xx.105 is my remote server

Any idea what I've done wrong?

Edit (Ubuntu) Firewall Rules

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
25/tcp (Postfix)           ALLOW IN    Anywhere                  
3306                       ALLOW IN    Anywhere                  
1935/tcp                   ALLOW IN    Anywhere                  
25/tcp (Postfix (v6))      ALLOW IN    Anywhere (v6)             
3306 (v6)                  ALLOW IN    Anywhere (v6)             
1935/tcp (v6)              ALLOW IN    Anywhere (v6)

rtmpdump result [rtmpdump -v -r "rtmp://rtmp.myserver.com/live/test" [ -s swf auth ] | vlc -]:

VLC media player 3.0.11.1 Vetinari (revision 3.0.11.1-0-g52483f3ca2)
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
WARNING: You haven't specified an output file (-o filename), using stdout
Connecting ...
[000055e60d2775b0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
QFont::fromString: Invalid description '(empty)'
QFont::fromString: Invalid description '(empty)'
ERROR: RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
[00007f6558001160] mjpeg demux error: cannot peek

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is not clear why this error is happening. The most popular issue with timeout is a firewall.

Another issue but i am not sure can be SWF authentication required.

Could you do a little more debugging, please?

  1. Show us your firewall rulles on the xx.xx.xx.105 server?
  2. Could you do some more debugging with the rtmpdump program? It will provide a lot of useful information required to solve your problem.
rtmpdump -v -r  "rtmp://rtmp.myserver.com:1935/" [ -s swf auth ]  | vlc -

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...