ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.47k stars 5.35k forks source link

GB: Failed to register device for IPv6 is not supported. Cannot register GB28181 device properly. #3402

Open phoenixZZZ opened 1 year ago

phoenixZZZ commented 1 year ago

Note: Please read FAQ before file an issue, see #2716

Description

Please description your issue here

  1. SRS Version: docker-srs:registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5

  2. SRS Log:

[2023-02-03 08:59:41.395][ERROR][1][t40bss97][11] SIP: Receive err code=3007(HttpParseUrl)(HTTP parse url failed) : parse message : set url=sip:34020000002000000001@3402000000, jsonp=0 : init uri http://2408:8210:30:9071:7e8a:e1ff:fed7:54ea/sip:34020000002000000001@3402000000 : parse url http://2408:8210:30:9071:7e8a:e1ff:fed7:54ea/sip:34020000002000000001@3402000000 as http://2408:8210:30:9071:7e8a:e1ff:fed7:54ea/sip:34020000002000000001@3402000000 failed, code=1
thread [1][t40bss97]: do_cycle() [./src/app/srs_app_gb28181.cpp:1076][errno=11]
thread [1][t40bss97]: parse_message() [./src/protocol/srs_protocol_http_conn.cpp:115][errno=11]
thread [1][t40bss97]: set_url() [./src/protocol/srs_protocol_http_conn.cpp:365][errno=11]
thread [1][t40bss97]: initialize() [./src/protocol/srs_protocol_http_stack.cpp:949][errno=11](Resource temporarily unavailable)
[2023-02-03 08:59:42.912][INFO][1][788y1bo6] Process: cpu=1.00%,80MB, threads=2
  1. SRS Config:
root@bhwl:/usr/local/srs/conf# cat gb28181.conf 

listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;

stream_caster {
    enabled on;
    caster gb28181;
    output rtmp://127.0.0.1/live/[stream];
    listen 9000;
    sip {
        enabled on;
        listen 5060;
        # @see https://ossrs.net/lts/zh-cn/docs/v5/doc/gb28181#config-candidate
        candidate $CANDIDATE;
    }
}

http_server {
    enabled on;
    listen 8080;
    dir ./objs/nginx/html;
}

http_api {
    enabled on;
    listen 1985;
}
stats {
    network 0;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}

vhost __defaultVhost__ {
    rtc {
        enabled on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp on;
    }
    http_remux {
        enabled on;
        mount [vhost]/[app]/[stream].flv;
    }
    hls {
        enabled on;
    }
}

Replay

Please describe how to replay the bug?

Step 1: Run docker using the image of SRS5 to test GB28181.

docker run -itd --network=host --name srs5 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 ./objs/srs -c conf/gb28181.conf

Step 2: Errors were encountered during both bench testing and real machine testing. Here is the execution of bench.

./objs/srs_bench -sfu gb28181 -pr tcp://192.168.2.153:5060 -user 3402000000 -random 10 -server 34020000002000000001 -domain 3402000000 -sa avatar.aac -sv avatar.h264 -fps 25

Expect

Expected to successfully register the GB28181 device, but encountered the error "Resource temporarily unavailable". Has anyone encountered this issue before? Please help with a solution.

TRANS_BY_GPT3

phoenixZZZ commented 1 year ago

The reason for this problem is that Ubuntu 20.04 by default enables IPV6, but SRS does not support IPV6 address resolution. Temporary solution:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

However, it is still hoped that SRS can support IPV6 access as soon as possible, not just limited to IPV4.

TRANS_BY_GPT3

winlinvip commented 1 year ago

Thank you for the answer, @phoenixZZZ.

Do GB devices need to support IPv6? Let's discuss whether local network IPv6 is sufficient.

TRANS_BY_GPT3

duiniuluantanqin commented 1 year ago

I took a look and found that Hikvision's devices now support IPv6. However, I have never used it before, so I'm checking out other people's feedback.

TRANS_BY_GPT3

phoenixZZZ commented 1 year ago

You can see from the logs that the IP address included in the address provided for device registration has now become IPv6. http://2408:8210:30:9071:7e8a:e1ff:fed7:54ea/sip:34020000002000000001@3402000000

This feature is not initiated by the hardware, but rather Ubuntu 20 has enabled the use of IPv6 by default. If IPv6 is not disabled during deployment, there will be a default IPv6 address present.

The devices I am using are not from Hikvision, but rather I am testing Dahua cameras and some camera modules. They do not recognize IPv6 addresses, so device registration is not functioning properly. Testing is being conducted in a local area network environment.

TRANS_BY_GPT3

duiniuluantanqin commented 1 year ago

In this case, considering the compatibility of old devices, should we proactively disable IPv6 instead of supporting it, right?

TRANS_BY_GPT3

phoenixZZZ commented 1 year ago

Hmm, but the best solution is not to disable IPv6 at the system level, but to handle it in SRS: Only use IPv4 addresses and not IPv6; if there is no IPv4 in the system, SRS will throw an exception and require user intervention.

Is this approach better?

TRANS_BY_GPT3