Closed feixuezhang closed 3 years ago
This may be a problem.
TRANS_BY_GPT3
From the packet capture, it can be seen that the server side has a response, but the device side keeps sending registration messages, only with an additional "heard" field in the Route domain. The server does not support the Route domain, so the confirmation messages in the response have some issues.
Route: sip:21030200001180000001@119.3.17.81:5060;lr
Attached packet capture message
Currently, we are using Dahua's NVR, and we have also encountered this issue with Hikvision's NVR.
TRANS_BY_GPT3
I also encountered the same problem. In the latest develop branch, Dahua camera. I initially thought there was a configuration issue somewhere. The device and server could not be registered despite various restarts. I don't know how to recover from this.
TRANS_BY_GPT3
@9dragon This is to support the SIP routing mechanism, which replies to SIP messages based on the routing header and corresponding addresses. You can refer to the following article for modification: https://blog.csdn.net/liaoxinmeng/article/details/7179376
TRANS_BY_GPT3
@9dragon This is to support the SIP routing mechanism, reply SIP messages to the corresponding address based on the routing header. You can refer to the following article for modification. https://blog.csdn.net/liaoxinmeng/article/details/7179376
Hello, how should this be modified? Do we include the route information in the response?
TRANS_BY_GPT3
@iceylm What is your host? I see you are using xxx.xxx.xxx.xxx? 119.3.17.81, Shanghai, Shanghai, Huawei Cloud; 113.228.8.225, Anshan City, Liaoning Province, China Unicom. What is your SRS internal IP? What is the public IP for 119.3.17.81 and 113.228.8.225?
It feels like there are some devices between the camera and SRS, such as Huawei Cloud SIP ALG or SIP Proxy. It doesn't seem right to receive packets with a Route header.
TRANS_BY_GPT3
@iceylm What is your host? I see you used xxx.xxx.xxx.xxx to represent it? 119.3.17.81, Shanghai, China on Huawei Cloud; 113.228.8.225, Anshan City, Liaoning Province, China on China Unicom. What is your SRS internal network IP 192.168.0.142? What is the public IP of 119.3.17.81 and 113.228.8.225?
I feel like there is some device between the camera and SRS, such as Huawei Cloud SIP ALG or SIP proxy. It doesn't seem like we should receive packets with the Route header.
@PieerePi The screenshot above was sent by other team members. The registration protocol I received during debugging is as follows:
REGISTER sip:34020000002000000001@172.17.0.11:55241 SIP/2.0 Via: SIP/2.0/UDP 58.246.230.45:55241;rport;branch=z9hG4bK2018295451 Route: sip:78978201001320000010@172.17.0.11:5060;lr From: sip:78978201001320000010@58.246.230.45:55241;tag=2033241836 To: sip:78978201001320000010@58.246.230.45:55241 Call-ID: 1835124422@192.168.1.109 CSeq: 1 REGISTER Contact: sip:78978201001320000010@58.246.230.45:5061 Max-Forwards: 70 User-Agent: SIP UAS V2.1.4.500306 Expires: 3600 Content-Length: 0
Those with this type of route cannot register. My SIP server IP is 121.4.176.246.
TRANS_BY_GPT3
Please explain all the addresses in your SIP package.
TRANS_BY_GPT3
Call-ID: 1835124422@192.168.1.109. This IP is the local IP of Dahua camera, and the other IP is the intermediate routing IP. My SIP server IP is 121.4.176.246.
TRANS_BY_GPT3
What is 172.17.0.11? What is 58.246.230.45? What is the source address and destination address of this packet?
Is SIP service SRS? 121.4.176.246 is the address of SRS. What is the internal network address of SRS?
Do Dahua cameras register directly with SRS, or do they require Dahua's platform?
TRANS_BY_GPT3
@PieerePi
What is 172.17.0.11? This is the internal address of SRS.
What is 58.246.230.45? This is the external IP of the camera.
What is the source address and destination address of this packet?Is SIP service SRS? Is 121.4.176.246 the address of SRS? What is the internal address of SRS?
Yes, SIP is connected to the SRS server, which is deployed on Tencent Cloud. The external address is 121.4.176.246, and the internal address of SRS is 172.17.0.11.Does Dahua camera directly register with SRS, or does it have its own platform? The camera platform I chose is gb28181, and I have set the SIP server address to the SRS server address 121.4.176.246.
TRANS_BY_GPT3
That means the camera is registered directly to SRS. Is the SIP port of SRS 5060? What is port 55241 for?
Did you do port forwarding for SRS on the public network? How did you configure the camera with the SIP server?
There must be SIP ALG in this. Tencent Cloud does not have EIP (which can be configured to enable or disable SIP ALG). SIP ALG is enabled by default, so I need to contact customer service to turn it off. However, since SRS directly returns a 200 OK message to the incoming address, it should be able to register successfully.
It's difficult to determine the network issue without packet capture and topology explanation.
TRANS_BY_GPT3
Two cameras in the same local network are both connected to the same Tencent Cloud SRS server, but the register messages received by SRS are different. The message for normal registration is: REGISTER sip:34020000002000000001@3402000000 SIP/2.0\r\n Via: SIP/2.0/UDP 58.246.230.45:5060;rport;branch=z9hG4bK2006538454\r\n From: sip:78978201001320000014@3402000000;tag=2051135311\r\n To: sip:78978201001320000014@3402000000\r\n Call-ID: 1279297768\r\n CSeq: 1 REGISTER\r\n Contact: sip:78978201001320000014@58.246.230.45:5060\r\n Max-Forwards: 70\r\n User-Agent: IP Camera\r\n Expires: 3600\r\n Content-Length: 0\r\n\r\n"
The message for registration failure is: REGISTER sip:34020000002000000001@172.17.0.11:55241 SIP/2.0 Via: SIP/2.0/UDP 58.246.230.45:55241;rport;branch=z9hG4bK2018295451 Route: sip:78978201001320000010@172.17.0.11:5060;lr From: sip:78978201001320000010@58.246.230.45:55241;tag=2033241836 To: sip:78978201001320000010@58.246.230.45:55241 Call-ID: 1835124422@192.168.1.109 CSeq: 1 REGISTER Contact: sip:78978201001320000010@58.246.230.45:5061 Max-Forwards: 70 User-Agent: SIP UAS V2.1.4.500306 Expires: 3600 Content-Length: 0
Both of these registration messages are sent from a LAN (local area network), with the external IP being 58.246.230.45. The configurations are from the same SRS (Server Registration Service) server.
TRANS_BY_GPT3
Registration failed. This registration agreement includes the route parameter. Is the 55241 port allocated by the router itself? Because port 5060 is already occupied by another camera.
TRANS_BY_GPT3
Normal registration return message: SIP/2.0 200 OK\r\n Via: SIP/2.0/UDP 58.246.230.45:5060;rport=5060;received=58.246.230.45;branch=z9hG4bK878839288\r\n From: sip:78978201001320000014@3402000000;tag=1971081623\r\n To: sip:78978201001320000014@3402000000\r\n CSeq: 1 REGISTER\r\n Call-ID: 1110626489\r\n Contact: sip:78978201001320000014@58.246.230.45:5060\r\n User-Agent: SRS/4.0.57(Leo)\r\n Expires: 3600\r\n Content-Length: 0\r\n\r\n"
Registration failure return message SIP/2.0 200 OK\r\n Via: SIP/2.0/UDP 58.246.230.45:55241;rport=55241;received=58.246.230.45;branch=z9hG4bK86879476\r\n From: sip:78978201001320000010@58.246.230.45:55241;tag=615913199\r\n To: sip:78978201001320000010@58.246.230.45:55241\r\n CSeq: 1 REGISTER\r\nCall-ID: 1528208607@192.168.1.109\r\n Contact: sip:78978201001320000010@58.246.230.45:5061\r\n User-Agent: SRS/4.0.57(Leo)\r\n Expires: 3600\r\n Content-Length: 0\r\n\r\n" It seems that this return message did not reach the camera end. The camera will keep requesting registration messages. Initially, the registration was successful and streaming could be played normally. However, after a period of time, it went offline and cannot register anymore.
TRANS_BY_GPT3
Cameras of the same brand? I can see that the User-Agent is different. Looking at the packet, it seems that the packet has been modified by an intermediate device. I believe there must be Tencent Cloud's SIP ALG because 172.17.0.11, your local network's gateway device, is definitely unaware of it. The packet should have reached the camera, but the camera refused it because the content has been altered.
I feel that you need to submit a work order to Tencent Cloud.
TRANS_BY_GPT3
Registration failed. This registration agreement includes "route". Is this 55241 port allocated by the router itself? Because 5060 is already occupied by another camera.
Can you try configuring the other camera with local SIP port 5061?
TRANS_BY_GPT3
Cameras of the same brand? I see the User-Agent is different. Look at the packet, it seems to have been modified by an intermediate device. I think there must be Tencent Cloud's SIP ALG because of 172.17.0.11. Your local network gateway device is probably unaware of it. The packet should have reached the camera, but the camera doesn't recognize it because the content has been altered.
I feel like you need to raise a work order with Tencent Cloud.
Tencent Cloud does not have EIP (configurable to enable or disable SIP ALG). SIP ALG is enabled by default, so you need to contact customer service to turn it off.
I also have machines on Tencent Cloud, running SIP services (at that time without running SRS), and I have submitted a work order to them to disable SIP ALG.
TRANS_BY_GPT3
Registration failed. This registration agreement includes a route, and this port 55241 is allocated by the router itself, right? Because port 5060 is already occupied by another camera.
Can you try configuring the other camera with the local SIP port 5061?
Hello, after modifying the local SIP port, this problem can be resolved. I will ask Tencent to disable SIP ALG again.
TRANS_BY_GPT3
Registration failed. The registration agreement includes "route". Is this 55241 port allocated by the router itself? Because 5060 is already occupied by another camera.
Can you try configuring the other camera with the local SIP port 5061?
Hi, after modifying the local SIP port, this issue can be resolved. I will also ask Tencent to disable SIP ALG.
Lucky!
TRANS_BY_GPT3
Registration failed. The registration agreement includes the route, is this 55241 port assigned by the router itself? Because 5060 is already occupied by another camera.
Could you try configuring the other camera as the local SIP port 5061?
Hi, changing the local SIP port can solve this issue. I will ask Tencent to disable SIP ALG.
Good luck!
Great master, are you saying that not disabling Tencent Cloud SIP ALG and even modifying the local SIP port may not ensure a successful registration? I don't quite understand the underlying principle, please guide me 🙏
TRANS_BY_GPT3
This is because the intermediate device, such as Tencent Cloud SIP ALG, modified the SIP packets. If Tencent Cloud SIP ALG is disabled, the cameras should be able to use port 5060 locally. I have encountered SIP ALG on both AWS and Tencent Cloud (non-EIP machines; EIP machines can be configured by the user to disable it). The built-in SIP ALG is too simplistic and should actually be disabled. It seems like the SIP ALG in your packets is encountering errors.
TRANS_BY_GPT3
@PieerePi Hello, after turning off SIP ALG, there is no longer a registration problem. However, there is now an occasional phenomenon where video streams are continuously pushed to SRS, but after a few hours, occasionally, the video stream is not received. Even restarting SRS does not receive the stream. Does this mean the camera has a problem? The camera is still online, but there is no video stream coming through, as shown in the following logs:
[2021-02-28 02:48:39.184][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001, ssrc=0x8ac005, peer(218.89.222.231, 9712), rtmp muxer is alive [2021-02-28 02:48:40.994][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=51,0,0, clock=0,46,2,0,0,0,0,0,0 [2021-02-28 02:48:46.101][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,0, timer=52,0,0, clock=0,46,2,0,0,0,0,0,0 [2021-02-28 02:48:46.970][Trace][6831][id43c83f] gb28181: sip session=34020000001320000001 peer(218.89.222.231, 5088) status(RegisterOk,AliveOk) duration(81,23) [2021-02-28 02:48:49.167][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001, ssrc=0x8ac005, peer(218.89.222.231, 9712), rtmp muxer is alive [2021-02-28 02:48:51.197][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=52,0,0, clock=0,46,2,0,0,0,0,0,0 [2021-02-28 02:48:56.303][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=51,0,0, clock=0,47,1,0,0,0,0,0,0 [2021-02-28 02:48:59.196][Trace][6831][3mj7hz2i] <- GBS gb28181: client_id , peer(218.89.222.231, 9712) ps rtp packet 26B, age=2079162774, vt=2/96, sts=29607/3644382000/0x8ac005, paylod=14B [2021-02-28 02:49:01.411][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=51,0,0, clock=0,47,1,0,0,0,0,0,0 [2021-02-28 02:49:06.523][Trace][6831][3mj7hz2i] Hybrid cpu=1.00%,15MB, cid=1,0, timer=51,0,0, clock=0,46,2,0,0,0,0,0,0 [2021-02-28 02:49:09.195][Trace][6831][3mj7hz2i] <- GBS gb28181: client_id , peer(218.89.222.231, 9712) ps rtp packet 26B, age=2089164874, vt=2/96, sts=30413/3645282000/0x8ac005, paylod=14B [2021-02-28 02:49:11.638][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=51,0,0, clock=0,46,2,0,0,0,0,0,0 [2021-02-28 02:49:16.722][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,0, timer=52,0,0, clock=0,47,1,1,0,0,0,0,0
[2021-02-28 02:49:16.881][Warn][6831][n0e83g12][11] gb28181: client id=34020000001320000001@34020000001320000001 ssrc=0x8ac005, peer(218.89.222.231, 9712), no rtp data 2 in seconds, clean it, wait other port!
[2021-02-28 02:49:21.468][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001, ssrc=0x8ac005, peer(, 0), rtmp muxer is alive [2021-02-28 02:49:21.787][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,0, timer=52,0,0, clock=0,47,1,1,0,0,0,0,0 [2021-02-28 02:49:26.851][Trace][6831][3mj7hz2i] Hybrid cpu=0.00%,15MB, cid=1,0, timer=52,0,0, clock=0,49,1,0,0,0,0,0,0 [2021-02-28 02:49:31.915][Trace][6831][3mj7hz2i] Hybrid cpu=0.00%,15MB, cid=1,0, timer=52,0,0, clock=0,49,1,0,0,0,0,0,0 [2021-02-28 02:49:36.482][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001, ssrc=0x8ac005, peer(, 0), rtmp muxer is alive [2021-02-28 02:49:36.981][Trace][6831][3mj7hz2i] Hybrid cpu=0.67%,15MB, cid=1,0, timer=52,0,0, clock=0,49,1,0,0,0,0,0,0 [2021-02-28 02:49:42.045][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,0, timer=52,0,0, clock=0,49,1,0,0,0,0,0,0 [2021-02-28 02:49:44.897][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001, stream idle timeout, stop!!! [2021-02-28 02:49:44.897][Trace][6831][n0e83g12] gb28181: client id=34020000001320000001@34020000001320000001 rtmp muxer is remove [2021-02-28 02:49:44.897][Trace][6831][n0e83g12] client finished. [2021-02-28 02:49:44.897][Trace][6831][747x8f06] cleanup when unpublish [2021-02-28 02:49:44.897][Trace][6831][747x8f06] cleanup when unpublish, created=1, deliver=1 [2021-02-28 02:49:47.001][Trace][6831][id43c83f] gb28181: sip session=34020000001320000001 peer(218.89.222.231, 5088) status(RegisterOk,AliveOk) duration(141,23) [2021-02-28 02:49:47.093][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,1, timer=52,0,0, clock=0,49,0,0,0,0,0,0,0, free=1 [2021-02-28 02:49:52.119][Trace][6831][3mj7hz2i] Hybrid cpu=0.00%,15MB, cid=1,1, timer=52,0,0, clock=0,49,0,0,0,0,0,0,0, free=1 [2021-02-28 02:49:57.145][Trace][6831][3mj7hz2i] Hybrid cpu=0.33%,15MB, cid=1,0, timer=52,0,0, clock=0,49,0,0,0,0,0,0,0
TRANS_BY_GPT3
@PieerePi 👍
After running for a while, the device goes offline and the log shows: 'sip: unknown message head Route'. The device's registration message cannot be recognized, and the server does not reply.
4.0.56
[2020-12-03 11:13:13.290][Trace][7812][777p511g] gb28181: request peer(113.228.8.225, 5061) nbbuf=498 [2020-12-03 11:13:13.290][Trace][7812][777p511g] gb28181: request recv message=REGISTER sip:44010600002000120002@xxx.xxx.xxx.xxx:5060 SIP/2.0 Via: SIP/2.0/UDP 113.228.8.225:5061;rport;branch=z9hG4bK142655506 Route: sip:21030200001180000001@xxx.xxx.xxx.xxx:5060;lr From: sip:21030200001180000001@113.228.8.225:5061;tag=1654407460 To: sip:21030200001180000001@113.228.8.225:5061 Call-ID: 1297672304@192.168.1.11 CSeq: 1 REGISTER Contact: sip:21030200001180000001@113.228.8.225:5061 Max-Forwards: 70 User-Agent: SIP UAS V2.1.4.662543 Expires: 3600 Content-Length: 0
[2020-12-03 11:13:13.290][Trace][7812][777p511g] sip: unkonw message head Route: content=sip:21030200001180000001@xxx.xxx.xxx.xxx:5060;lr [2020-12-03 11:13:13.290][Trace][7812][777p511g] gb28181: request client id=21030200001180000001 peer(113.228.8.225, 5061) [2020-12-03 11:13:13.290][Trace][7812][777p511g] gb28181: request method=REGISTER, uri=sip:44010600002000120002@xxx.xxx.xxx.xxx:5060, version=SIP/2.0 expires=3600 [2020-12-03 11:13:13.290][Trace][7812][777p511g] gb28181: send_message:SIP/2.0 200 OK Via: SIP/2.0/UDP 113.228.8.225:5061;rport=5061;received=113.228.8.225;branch=z9hG4bK142655506 From: sip:21030200001180000001@113.228.8.225:5061;tag=1654407460 To: sip:21030200001180000001@113.228.8.225:5061 CSeq: 1 REGISTER Call-ID: 1297672304@192.168.1.11 Contact: sip:21030200001180000001@113.228.8.225:5061 User-Agent: SRS/4.0.56(Leo) Expires: 3600 Content-Length: 0
push gb28181 stream to SRS.
listen 1935; max_connections 1017; daemon on; srs_log_tank console; # Configure logging to print to console, needs to be used in conjunction with srs_log_level. srs_log_file ./objs/srs.log; utc_time off; # Whether to use UTC time. If this value is off, local time will be used. If it is on, UTC time will be used.
http_api {
whether http api is enabled.
}
stats {
the index of device ip.
}
stream_caster { enabled on; caster gb28181;
Forward the stream to the RTMP server address and port.
[stream] is the VideoChannelCodecID for SIP.
The automatically created channel for [stream] is 'chid[ssrc]', where [ssrc] is the SSRC for RTP.
[ssrc] is the SSRC in RTP.
The multiplexing port for receiving RTP streams from the device side.
The minimum value of the range of listening ports for receiving RTP.
The maximum value of the range of listening ports for receiving RTP.
Whether to wait for a keyframe before forwarding.
off: No need to wait, forward directly.
on: Wait for the first keyframe before forwarding.
Idle waiting time for RTP packets. If no packets are received within the specified time,
the RTP listening connection will automatically stop and send a BYE command.
Whether to forward audio stream.
Currently only supports AAC format, so the device needs to support AAC format.
on: forward audio.
off: do not forward audio, only video.
Note!!!: FLV only supports three sample rates: 11025, 22050, 44100.
If the device does not support any of these three, it will automatically select one format during forwarding.
It will also encapsulate the ADTS header in the FLV AAC raw data.
In this way, the player can automatically select the sampling frequency through the ADTS header.
Players like ffplay and VLC can do this, but Flash does not have sound support.
This is because Flash only supports sample rates of 11025, 22050, 44100.
Whether to enable RTP buffering.
Enabling it can effectively solve issues such as RTP packet disorder.
Server host, can be a domain name or IP address.
This is the address where the device sends media. If the server is in an internal or external network, the external address needs to be specified.
When calling the API to create a stream session, the returned IP address is also the host.
$CANDIDATE is a system environment variable used to get the address. If it is not configured, use *.
* represents the network card address specified for "stats network". If no network card is configured, the default is the address of the 0th network card.
Create an RTMP media channel based on the received PS RTP packets, no need to create it through an API interface.
The RTMP address parameter [stream] is the channel ID in the format chid[ssrc].
Enable internal SRS SIP signaling or not.
Set it to "on" to enable signaling through SRS, and "off" to only forward PS streams.
SIP listening UDP port.
SIP server ID.
Device-side configuration number needs to be consistent with this value, otherwise registration will not be possible.
SIP server domain.
The timeout for receiving a response after sending an ACK from the server, in seconds.
If there is no response within the specified time, it is considered a failure.
The time for maintaining device heartbeat. If no heartbeat is received within the specified time (in seconds),
it is considered that the device is offline.
Whether to automatically send an invite to the device after registration.
"on" means yes, "off" means no. It needs to be controlled through the API.
Whether the port for sending streams from the device is fixed.
"on" means the stream will be sent to a multiplexing port such as 9000.
"off" means it will automatically choose a port from the range between rtp_mix_port and rtp_max_port that is available.
The interval (in seconds) for querying the device list from the device or subordinate domain.
The default interval is 60 seconds.
}