Hi. Im trying to implement pooling service that will with some periods retreive PTZ information about camera.
I use XProtect Corporate 2018 R3
I try to use ImageServer session to an XProtect Recording Server.
I able to connect using sockets with this code(Node js example) :
const net = require('net');
const client = net.Socket();
client.connect(7563, 'host');
client.setKeepAlive(true);
client.on('data', (data) => console.log(data.toString()));
client.on('error', (err) => console.log("ERROR"));
client.on('close', () => console.log("Closed"));
client.on('connect', function(data) {
var login = `<?xml version="1.0" encoding="UTF-8"?><methodcall><requestid>1</requestid><methodname>connect</methodname><username>dummy</username><password>dummy</password><cameraid>[myCameraId]</cameraid><connectparam>id=[myCameraId]&connectiontoken=[myToken]</connectparam></methodcall>\r\n\r\n`;
client.write(login);
});
From this snippet i receive success response like this :
<?xml version="1.0" encoding="UTF-8"?><methodresponse><requestid>1</requestid><methodname>connect</methodname><connected>yes</connected><errorreason>Success</errorreas
on><includehasmotionflags>no</includehasmotionflags><includesequencenumber>no</includesequencenumber><includesignatures>no</includesignatures><alwaysstdjpeg>no</always
stdjpeg><transcode><allframes>no</allframes></transcode><clientcapabilities><privacymask>no</privacymask><privacymaskversion>0</privacymaskversion><multipartdata>no</m
ultipartdata><datarestriction>no</datarestriction></clientcapabilities><servercapabilities><connectupdate>yes</connectupdate><signatures>yes</signatures></servercapabi
lities></methodresponse>
Now i can use some methods from documentation like :
ptz
ptzcenter
But when it try to send ptzgetabsoluteposition
//try to get camera PTZ
var ptz = `<?xml version="1.0" encoding="UTF-8"?><methodcall><requestid>1</requestid><methodname>ptzgetabsoluteposition</methodname><deviceid><guid>[deviceId]</guid></deviceid></methodcall>\r\n\r\n`;
client.write(ptz);
I receive error
HTTP/1.1 400 Method ‘ptzgetabsoluteposition’ not implemented
I see that this method uses POST request to obtain data.
Now my question is. Will i be able to receive this data using socket connection or im forced to use HTTP POST request to /RecorderCommandService/RecorderCommandService.asmx
which works fine.
Update:
I tried to wrap porst request data into string and send via socket. Here is what i get :
var ptz = `POST /imageserver?methodcall=ptzgetabsoluteposition HTTP/1.1\r\nContent-Type: text/xml;\r\nX-Protocol: lean\r\nX-RequestId: 3\r\nAccept-Encoding: identity\r\nContent-Length: 137\r\nHost: windev1809eval:7563\r\nAuthorization: Basic YWStaW46YWRtaW2=\r\n\r\n<?xml version='1.0' encoding='UTF-8'?><methodcall><deviceid><guid>[myCameraId]</guid></deviceid></methodcall>\r\n\r\n`;
client.on('connect', function(data) {
//login requests here. Which return OK info
//try to get camera PTZ
client.write(ptz );
});
This return response like this :
HTTP/1.1 403 Forbidden
Content-Length: 0
X-MethodName: ptzgetabsoluteposition
X-RequestId: 3
If i try to remove \r\n after Authorization to make sure than request ends after xml data i get
client.write(`POST /imageserver?methodcall=ptzgetabsoluteposition HTTP/1.1\r\nContent-Type: text/xml;\r\nX-Protocol: lean\r\nX-RequestId: 3\r\nAccept-Encoding: identity\r\nContent-Length: 137\r\nHost: windev1809eval:7563\r\nAuthorization: Basic YWRtaW46YWRtaW4=\r\n<?xml version='1.0' encoding='UTF-8'?><methodcall><deviceid><guid>[MyCameraId]</guid></deviceid></methodcall>\r\n\r\n`);
Response :
HTTP/1.1 400 Bad Request
Content-Type: text/xml
Content-Length: 35
Connection: Keep-Alive
<h1>HTTP/1.1 400 Bad Request</h1>
Maybe im missing something obviuos.
Thank you.