Page 1 of 1

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

Posted: Sat Sep 24, 2016 6:57 pm
by laurentmartin

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: -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 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




I tried the onvif npm (nodejs) :

Code: Select all

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

I tried also with the following ruby code:

Code: Select all

#!/usr/bin/env ruby

require 'socket'
require 'ipaddr'
require 'timeout'
PORT = 3702

probemsg='<s:Envelope xmlns:s="" xmlns:a="">
    <a:Action s:mustUnderstand="1"></a:Action>
    <a:To s:mustUnderstand="1">urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01</a:To>
    <Probe xmlns="">
      <d:Types xmlns:d="" xmlns:dp0="">dp0:NetworkVideoTransmitter</d:Types>

ip = +"").hton
sock =
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)

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

it works perfect.

So, it's either that 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="" xmlns:xsi="" >
    <Action xmlns=""></Action>
    <MessageID xmlns="">urn:uuid:05253542-8285-11E6-9555-AA1CD56BB8A0</MessageID>
    <To xmlns="">urn:schemas-xmlsoap-org:ws:2005:04:discovery</To>
    <Probe xmlns="" xmlns:dn="" xmlns:tds="">
      <Types>dn:NetworkVideoTransmitter tds:Device</Types>

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="" xmlns:xsi="" xmlns:a="">
    <Probe xmlns="" xmlns:dn="" xmlns:tds="">
      <Types>dn:NetworkVideoTransmitter tds:Device</Types>
it shows that it is a problem in the camera ...