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

Error: already publishing #1756

Open
DattatrayHinge opened this issue Feb 26, 2024 · 4 comments
Open

Error: already publishing #1756

DattatrayHinge opened this issue Feb 26, 2024 · 4 comments

Comments

@DattatrayHinge
Copy link

DattatrayHinge commented Feb 26, 2024

Hi

I am getting below error with 4G cameras streaming on rtmp
2023/09/28 14:48:46 [error] 13#13: *849 live: already publishing, client: xx.xx.xx.xx, server: 0.0.0.0:1935

Note: There are a few 4G cameras streaming to this rtmp server at the same time, I am not sure if this is due to the 4G network or something wrong in my nginx config. I am using the latest tiangolo/nginx-rtmp image

My Nginx File

user www-data;
worker_processes auto;
rtmp_auto_push on;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 4096;
    accept_mutex on;
}

rtmp {
    log_format new '[$time_local-$remote_addr]: $command:$app:$name, Args=$args, Recv=$bytes_received, Sent=$bytes_sent, url=$pageurl, flashver=$flashver,  session_readable_time=$session_readable_time, Connection=$connection';

    server {
        listen 1935;
        listen [::]:1935 ipv6only=on;
        chunk_size 4096;

        timeout 60s;
        ping 3m;
        ping_timeout 30s;

        access_log /var/log/nginx/rtmp_access.log new;
	access_log /var/log/nginx/rtmp_access.log;

        # HLS
        hls on;
        hls_path /tmp/hls;
        hls_fragment 10s; # default is 5s
        hls_playlist_length 10m; # default is 30s
        # once playlist length is reached it deletes the oldest fragments
        # hls_continuous on;

        application live {
            live on;
            record off;

            # Auth 
            on_publish http://myserver.com/api/v1/auth;
        }
    }
}
@luiscovelo
Copy link

@DattatrayHinge Hi,

This problem refers when you are streaming twice or more streams with same stream key, for example.

Camera 1: rtmp://my-server.com/live/streamkey1
Camera 2: rtmp://my-server.com/live/streamkey1
Camera 3: rtmp://my-server.com/live/streamkey2

In this case, the cameras 1 and 2 it will conflict, each camera must have a unique stream key configured.

Search to use a custom RTMP address, this way you can to inform a unique stream key in each camera avoiding the already publishing error.

See this video in how to configure a custom RTMP address into a Dahua device: https://youtu.be/7bl1_94ZwEU?si=74TYqOR4Disbqa_h&t=80

Best regards

@DattatrayHinge
Copy link
Author

DattatrayHinge commented Apr 25, 2024 via email

@NKNdevs
Copy link

NKNdevs commented Jun 7, 2024

I'm experiencing this error too, on a server that has been running without issue for several years, but recently has started stopping streaming/recording randomly. When the stream/recording experiences problems, I find these errors in the logs (most of the time).
In our setup there is only one streaming client, who needs authorization to connect, and the IP is always the same before and after the interruptions. So I'm guessing the client disconnects momentarily, but then when they try to reconnect, the server tells them they're already connected. Does this sound likely?
I've been reading for possible fixes. I've seen that setting 'ping 10s;' can help. I've also read that setting a so_keepalive value in the listen directive can help. Would those seem like possible solutions? I'd like to understand what they do before implementing them.

@NKNdevs
Copy link

NKNdevs commented Jun 7, 2024

Adding more info. So when there's an interruption I get these lines in the error log, and rtmp.log respectively

2024/06/06 19:25:55 [error] 201701#201701: *49130 live: already publishing, client: 73.15.16.17, server: 0.0.0.0:1935
2024/06/06 19:26:13 [error] 201701#201701: *49151 live: already publishing, client: 73.15.16.17, server: 0.0.0.0:1935

73.15.16.17 [06/Jun/2024:19:25:34 +0000] PUBLISH "appname" "stream" "" - 468 412 "" "FMLE/3.0 (compatible; FMSc/1.0)" (0s)
73.15.16.17 [06/Jun/2024:19:25:43 +0000] PUBLISH "appname" "stream" "" - 468 412 "" "FMLE/3.0 (compatible; FMSc/1.0)" (1s)

The relevant lines in my rtmp/nginx config are.

user www-data;
# worker_processes auto might cause stream start/stop not to work, so try =1 instead
# From https://github.com/arut/nginx-rtmp-module/wiki/Control-module
# worker_processes auto;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
	    buflen 5s;

        application appname {
            live on;
	    	access_log /var/log/nginx/rtmp.access.log;
	        hls on;
    	    hls_path /srv/streaming/tv/tvhls;
        	hls_cleanup off;
       		hls_sync 100ms;
        	hls_fragment 300ms;

	        dash on;
	        dash_path /srv/streaming/tv/tvdash;
	        dash_cleanup off;

	        recorder videostream {
	                -# record all manual;
	                record all;
			record_path /srv/streaming/tv/tvrec;
	                record_suffix -%Y-%m-%d-%H-%M.flv;
	                record_unique on;
	            }
	    }

    }
}


http {
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	directio 512;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	server_tokens off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

}

Nginx version is standard 1.18 from ubuntu repos. Considering upgrading to 1.26 if that will help.

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