onvif probe not working (camera does not accept default namespace)

Forum for questions and support relating to the 1.30.x releases only.
Locked
laurentmartin
Posts: 2
Joined: Mon Mar 14, 2016 10:42 pm

onvif probe not working (camera does not accept default namespace)

Post by laurentmartin »

Hello,

I have an onvif camera (szsinocam SN-IPC-5024CSW).
It works well with zoneminder (1.30, ubuntu, iconnor), in either snapshot or rtsp mode.

I would like to discover the camera with zoneminder.
for instance, I execute:
zmonvif-probe.pl -v probe
-> no detection.

Basically, I tracked it down to the fact that the camera does not accept the xml default namespace in "Action", "Message" and "To" tags in the probe message. Instead it seems to expect the prefix notation.

Is it possible to have zmonvif-probe.pl to use a prefix for the "addressing" namespace, instead of default notation ?

For the time being I fixed my issue by adding:

Code: Select all

  $bytes=~s{<([A-Z][a-zA-Z]+ xmlns)(="[^"]+/addressing">[^<]+</)([^>]+>)}{<a:$1:a$2a:$3}g;
just before the line:

Code: Select all

  $socket->send($bytes);
in TransportUDP.pm

Thanks
Laurent







details:


I tried the onvif npm (nodejs) : https://www.npmjs.com/package/onvif

Code: Select all

var onvif = require('onvif');
onvif.Discovery.on('device', function(cam){console.log(cam);})
onvif.Discovery.probe();
it works perfect.

I tried also with the following ruby code:

Code: Select all

#!/usr/bin/env ruby

require 'socket'
require 'ipaddr'
require 'timeout'
MULTICAST_ADDR = "239.255.255.250" 
PORT = 3702

probemsg='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
    <a:MessageID>urn:uuid:cd376dcb-e7af-8566-7591-4f0158c65ed0</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01</a:To>
  </s:Header>
  <s:Body>
    <Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery">
      <d:Types xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dp0="http://www.onvif.org/ver10/network/wsdl">dp0:NetworkVideoTransmitter</d:Types>
    </Probe>
  </s:Body>
</s:Envelope>
'

ip =  IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("0.0.0.0").hton
sock = UDPSocket.new
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
#  socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [1].pack('i'))
sock.bind(Socket::INADDR_ANY, PORT)

sock.send(probemsg, 0, MULTICAST_ADDR, PORT)

begin
    status = Timeout::timeout(2) {
loop do
  msg, info = sock.recvfrom(1500)
  puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}" 
end
}
rescue
end

sock.close 
it works perfect.

So, it's either that zmonvif-probe.pl doesnt somehow send a correct message. But as far as I understand, zm sends messages compiled from the official WSDL.
Or that the camera is limited in the type of message it accepts.

The message I see sent from zm is:

Code: Select all

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <SOAP-ENV:Header>
    <Action xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</Action>
    <MessageID xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:uuid:05253542-8285-11E6-9555-AA1CD56BB8A0</MessageID>
    <To xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</To>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
      <Types>dn:NetworkVideoTransmitter tds:Device</Types>
      <Scopes></Scopes>
    </Probe>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So, I tried to feed this msg template into the script: does not work (of course), no answer

But if I use the namespace prefix notation for "addressing" tags, it works .. like this:

Code: Select all

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
  <SOAP-ENV:Header>
    <a:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</Action>
    <a:MessageID>urn:uuid:05253542-8285-11E6-9555-AA1CD56BB8A0</MessageID>
    <a:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</To>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
      <Types>dn:NetworkVideoTransmitter tds:Device</Types>
      <Scopes></Scopes>
    </Probe>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
it shows that it is a problem in the camera ...
Locked