HikVision DS-K2600 Device: NET_DRV_Login_V40 return Error Code -41 NET_DVR_ALLOCRESOURCE_ERROR

Pier Aisa

n3wb
Joined
Jul 16, 2020
Messages
1
Reaction score
0
Location
Italy
Here is my C++ code, I can't login to the HikVision DS-K2600 Device, because I receive back an Login failed with error Code -41 NET_DVR_ALLOCRESOURCE_ERROR.
Thanks in advance

#include <stdio.h>
#include <iostream>
#include <afx.h>
#include "Windows.h"
#include "HCNetSDK.h"
#pragma comment(lib, "HCNetSDK.lib")
#pragma comment(lib, "HCCore.lib")
using namespace std;

void main()
{
/---------------------------------------
/Initialize
NET_DVR_Init();

/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);

/---------------------------------------
/Initialize
NET_DVR_Init();

/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
/---------------------------------------
/Log in to device
LONG lUserID;
/Login parameters, including device IP address, user name, password, and so on
NET_DVR_USER_LOGIN_INFO struLoginInfo = { 0 };
struLoginInfo.bUseAsynLogin = 0; /Synchronous login mode
strcpy_s(struLoginInfo.sDeviceAddress, "192.168.0.64"); /Device IP address
struLoginInfo.wPort = 8000; /Device service port number
strcpy_s(struLoginInfo.sUserName, "admin"); /User name
strcpy_s(struLoginInfo.sPassword, "Mobiliere.10"); /Password

/Device information, output parameter
NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = { 0 };

lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
if (lUserID < 0)
{
printf("Login failed, error code: %d\n", NET_DVR_GetLastError());
NET_DVR_Cleanup();
return;
}

/Open door, take door 1 as an example
BOOL bRet;
LONG lGatewayIndex = 1;/Access controller No., starts from 1, -1: control all doors
DWORD dwStaic = 1;/Command No.: 0-Close, 1-Open, 2-Remain Open, 3-Remain Closed

bRet = NET_DVR_ControlGateway(lUserID, lGatewayIndex, dwStaic);
if (!bRet)
{
printf("NET_DVR_ControlGateway failed, error:%d\n", NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;
}

/---------------------------------------
/Exit
Sleep(5000);

/Log out
NET_DVR_Logout(lUserID);
/Release SDK resource
NET_DVR_Cleanup();
return;
}
 

Dominik21

Young grasshopper
Joined
May 25, 2023
Messages
46
Reaction score
8
Location
Germany
Is there any solution? I've the same problem. Does somebody know which resource isn't allocated correctly?
In wireshark I can see the difference to the communication between the camera and a program from the sdk from hikvision. It seems that the username and the password aren't transmitted.
In the sdk are used NET_DVR_DEVICEINFO_V30 and NET_DVR_Login_V30 instead of NET_DVR_DEVICEINFO_V40 and NET_DVR_Login_V40 but i tried both.
 

Attachments

Dominik21

Young grasshopper
Joined
May 25, 2023
Messages
46
Reaction score
8
Location
Germany
Now it works... First I tried this Code in Linux but it didnt worked... In Windows with the libs, dlls, and header-files from the SDK it works.
 
Top