Encapsulation SDK Call Error: runtime error [How to Solve]

In addition to accessing RTSP and gb28181, it also completes the docking with the equipment and video stream transmission through private protocols such as hiksdk and EHOME.

The client server deployed the easycvr project and crashed after running for a period of time. Open the log. The error message is as follows: “runtime error: invalid memory address or nil pointer dereference”.

This error is a typical error caused by the direct use of the go pointer without initializing the pointer after it is declared. See the addstream function in line 516 of the error information view code. The following code indicates that this function is the key to the error and is saved as the error file information, so this is not the key to the error.

Check the error message at line 606:

The parameters in line 606 represent: channel name, stream address, channel ID, handle using SDK, channelnum and stream type. Therefore, compared with the previous error message, it will be associated with the problem of calling the SDK handle. Then view the local. DB database for comparison:

Field Dahua_ device_ Handle has two values of 0 and – 1. All these two values are only available when login fails or errors occur. The program uses this value directly. This will cause the call to. DLL and. So to crash.

Before calling the SDK, make the following judgment when passing in the handle:

If loginHandle <=0 {
	Return -1, fmt.Errorf(“handle param error:%d”, loginHandle)

Or directly make if judgment in the encapsulated DLL. This is for double insurance.

if (loginHandle <= 0) {
	return -1;

Read More: