Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When set discovery mode to 'netscan', not get any devices,Please help! #134

Closed
edgego opened this issue Aug 15, 2022 · 18 comments
Closed

When set discovery mode to 'netscan', not get any devices,Please help! #134

edgego opened this issue Aug 15, 2022 · 18 comments
Assignees
Labels
bug Something isn't working hikvision Hikvision camera question Further information is requested

Comments

@edgego
Copy link
Contributor

edgego commented Aug 15, 2022

Dear :
Run the service ( version 2.2.0 ) via docker-compose , did not discovery any devices , but indeed there is a hikvsion ip camera with ip 192.168.1.64. Following is the configuration for AppCustom
[AppCustom]
DiscoverySubnets = "192.168.1.0/24"
ProbeAsyncLimit = 4000
CredentialsRetryTime = 120
CredentialsRetryWait = 1
RequestTimeout = 5
DiscoveryEthernetInterface = "eth0"
DefaultSecretPath = "credentials001"
BaseNotificationURL = "http://support-notifications:59860"
DiscoveryMode = "netscan"
ProbeTimeoutMillis = 2000
EnableStatusCheck = true
CheckStatusInterval = 30
MaxDiscoverDurationSeconds = 300

Following is the debug information:
level=INFO ts=2022-08-15T12:10:22.184536316Z app=device-onvif-camera source=message.go:55 msg="device-onvif-camera started"
.....
level=TRACE ts=2022-08-15T12:10:22.281623646Z app=device-onvif-camera source=discover.go:192 msg="Dial: 192.168.1.64:3702"

...................

level=TRACE ts=2022-08-15T12:10:24.195908604Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.64:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.27977074Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.245:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.279803249Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.243:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.27991991Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.247:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.280981424Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.251:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.281045541Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.250:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.281074212Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.189:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.281001277Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.221:3702: No Response"
level=TRACE ts=2022-08-15T12:10:24.281141973Z app=device-onvif-camera source=onvifdiscovery.go:209 msg="192.168.1.252:3702: No Response"
lmsg="192.168.1.112:3702: No Response"
level=DEBUG ts=2022-08-15T12:10:24.301456498Z app=device-onvif-camera source=driver.go:633 msg="NetScan result: []"
level=INFO ts=2022-08-15T12:10:24.301466184Z app=device-onvif-camera source=driver.go:634 msg="Discovered 0 device(s) in 2.116462574s via netscan."
level=DEBUG ts=2022-08-15T12:10:24.301484293Z app=device-onvif-camera source=async.go:127 msg="Filtered device addition finished"

@edgego edgego added the question Further information is requested label Aug 15, 2022
@ajcasagrande
Copy link
Contributor

I believe this is related to another auto-discovery issue I am tracking down. If that is the case, it should be fixed in the next few days.

Here is something to try in the meantime to check if it will work with the work-in-progress discovery fix:

Open a UDP connection to the camera on port 3702 using netcat:

nc -u 192.168.1.64 3702

Paste this entire xml message as-is, and then hit Enter if needed.

<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding">
   <soap-env:Header>
      <a:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
      <a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d1c</a:MessageID>
      <a:To mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
   </soap-env:Header>
   <soap-env:Body>
      <d:Probe>
         <d:Types>dn:NetworkVideoTransmitter</d:Types>
      </d:Probe>
   </soap-env:Body>
</soap-env:Envelope>

You should hopefully get an xml message back from the camera, containing things such as ProbeMatch and XAddrs if successful. If you wouldn't mind posting that here, that would be helpful as well.

Ctrl-C to close the connection.

@edgego
Copy link
Contributor Author

edgego commented Aug 16, 2022

@ajcasagrande thanks for reply, following is the back :

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnshik="http://www.hikvision.com/2011/event/topics" xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema" xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:axt="http://www.onvif.org/ver20/analytics"><env:Header><wsadis:MessageID></wsadis:MessageID>
<wsadis:RelatesTo>uuid:4d44d0f8-677c-4bd7-87fb-5f57ed8bda75</wsadis:RelatesTo>
<wsadis:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/fault</wsadis:Action>
</env:Header>
<env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value>
<env:Subcode><env:Value>d:MatchingRuleNotSupported</env:Value>
</env:Subcode>
</env:Code>
<env:Reason><env:Text xml:lang="en">the xml format error</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>

@ajcasagrande
Copy link
Contributor

ajcasagrande commented Aug 16, 2022

@edgego That is an interesting response, I have not seen that before. The MatchingRuleNotSupported leads me to believe that it doesn't support filtering by device type (ie. NetworkVideoTransmitter), but the <env:Text xml:lang="en">the xml format error</env:Text> makes me think it did not like the xml value sent in.

Can you try sending the following different messages and seeing if any of them respond better? Make sure to close the connection and start a new one each time using the nc -u 192.168.1.64 3702

NOTE: It is possible sometimes the camera will not respond anything back. Assume that means it didn't like the message.

without xml header:

<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding">
   <soap-env:Header>
      <a:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
      <a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d2c</a:MessageID>
      <a:To mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
   </soap-env:Header>
   <soap-env:Body>
      <d:Probe>
         <d:Types>dn:NetworkVideoTransmitter</d:Types>
      </d:Probe>
   </soap-env:Body>
</soap-env:Envelope>

without dn:NetworkVideoTransmitter filter

<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding">
   <soap-env:Header>
      <a:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
      <a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d3c</a:MessageID>
      <a:To mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
   </soap-env:Header>
   <soap-env:Body>
      <d:Probe>
      </d:Probe>
   </soap-env:Body>
</soap-env:Envelope>

without xml header and without dn:NetworkVideoTransmitter filter

<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding">
   <soap-env:Header>
      <a:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
      <a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d4c</a:MessageID>
      <a:To mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
   </soap-env:Header>
   <soap-env:Body>
      <d:Probe>
      </d:Probe>
   </soap-env:Body>
</soap-env:Envelope>

without any new-lines

<?xml version="1.0" encoding="UTF-8"?><soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding"><soap-env:Header><a:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action><a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d2c</a:MessageID><a:To mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To></soap-env:Header><soap-env:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></soap-env:Body></soap-env:Envelope>

@edgego
Copy link
Contributor Author

edgego commented Aug 17, 2022

@ajcasagrande thanks , the last without any new-lines packet works , response as following:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnshik="http://www.hikvision.com/2011/event/topics" xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema" xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:axt="http://www.onvif.org/ver20/analytics"><env:Header><wsadis:MessageID>urn:uuid:617dc000-4574-11b4-82be-2428fdc5062f</wsadis:MessageID>
<wsadis:RelatesTo>uuid:a277f13a-ecae-4492-9d6a-218982122d2c</wsadis:RelatesTo>
<wsadis:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsadis:To>
<wsadis:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsadis:Action>
<d:AppSequence InstanceId="1660727855" MessageNumber="4"/>
</env:Header>
<env:Body><d:ProbeMatches><d:ProbeMatch><wsadis:EndpointReference><wsadis:Address>urn:uuid:617dc000-4574-11b4-82be-2428fdc5062f</wsadis:Address>
</wsadis:EndpointReference>
<d:Types>dn:NetworkVideoTransmitter tds:Device</d:Types>
<d:Scopes>onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/Profile/G onvif://www.onvif.org/Profile/T onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/ptz onvif://www.onvif.org/MAC/24:28:fd:c5:06:2f onvif://www.onvif.org/hardware/DS-2DE2402IW-D3/W/XM onvif://www.onvif.org/name/HIKVISION%20DS-2DE2402IW-D3/W/XM onvif://www.onvif.org/location/city/hangzhou</d:Scopes>
<d:XAddrs>http://192.168.1.64/onvif/device_service</d:XAddrs>
<d:MetadataVersion>10</d:MetadataVersion>
</d:ProbeMatch>
</d:ProbeMatches>
</env:Body>
</env:Envelope>

@edgego
Copy link
Contributor Author

edgego commented Aug 17, 2022

But inside docker container the command 'nc -u 192.168.1.64 3702' always hanging up after input soap packet. From outside dcoker container can get response

@ajcasagrande
Copy link
Contributor

@edgego please test with the latest docker images:

nexus3.edgexfoundry.org:10004/device-onvif-camera:latest
or
nexus3.edgexfoundry.org:10004/device-onvif-camera:2.3.0-dev.8

@edgego
Copy link
Contributor Author

edgego commented Sep 1, 2022

@ajcasagrande Thanks, tested both images:nexus3.edgexfoundry.org:10004/device-onvif-camera:latest and nexus3.edgexfoundry.org:10004/device-onvif-camera:2.3.0-dev.8, still can not discovery camera . And also run command : nc -u 192.168.1.64 3702 inside the docker , hung up when input xml packet that you provided.
Probably this issue is due to WS-Discovery muiticast on 3702 only working on local docker network . But camera network same as host network, that is different network with docker network. So need implement remote discovery.

Following two log files for both images.

logs-from-device-onvif-camera-in-device-onvif-camera-8c567c86d-bd5k6.log
logs-from-device-onvif-camera-in-device-onvif-camera-5b75dfd88c-vgmgc.log

@ajcasagrande
Copy link
Contributor

@edgego When using netscan there is no multicast message, but instead a unicast UDP probe over port 3702. This works behind the docker networks unlike the multicast version. There are many devices we have validated to work using this approach.

One potential cause of this is the camera is sending the response to the probe in a way or to an address that is not properly routable back to the docker container/device service. I have seen similar problems like this with the Happytime Simulator (it receives the probe, but the response is lost). This is why even when using nc ... you do not get a response in docker.

It might be possible to force it to respond properly by filling out the ReplyTo fields of the probe.

If we ever implement #137 that could help aleviate this issue.

@edgego
Copy link
Contributor Author

edgego commented Sep 3, 2022

@ajcasagrande Thanks for reply. The ReplyTo field is the source ip and port of probe packet, when sent probe packet from docker, the source ip is the docker container's ip address , or the source ip is host's ip ? Also change wsdiscovery.BuildProbeMessage to build soap probe request?

@edgego
Copy link
Contributor Author

edgego commented Sep 10, 2022

@ajcasagrande
Copy link
Contributor

thanks. A mixture of your links and playing around with the ReplyTo field, we may be able to resolve the issue. I do not own any cameras which exhibit this kind of behavior, but it may be possible to debug using the Happytime simulator.

@edgego Would you mind sharing the exact model number of your camera?

@ajcasagrande ajcasagrande added the hikvision Hikvision camera label Sep 15, 2022
@edgego
Copy link
Contributor Author

edgego commented Sep 17, 2022

@ajcasagrande Thx, camera model : hikvision DS-2DE2402IW-D3/W/XM,seiral no : G29457470

@edgego
Copy link
Contributor Author

edgego commented Sep 20, 2022

@ajcasagrande Would you please tell how to get image resolution from dtos.Event reading ? Can get image from Snapshot comamnd , but no image resolution. Thanks !

@ajcasagrande
Copy link
Contributor

@edgego In general, you should create separate Github Issues for these, so they can be tracked better.

The GetSnapshot command only sends the image binary. Currently due to #122 only the first profile is supported for getting the snapshot. So I believe you have 2 options:

  1. Decode the snapshot and use a library that supports decoding image formats to read the image metadata, or
  2. Call GetProfiles and find the video resolution of the first Profile. This should hopefully match the image resolution.

@edgego
Copy link
Contributor Author

edgego commented Oct 2, 2022

Thanks , followed 1st option , resolved image resolution issue

@lenny-goodell
Copy link
Member

question answered, closing issue

@ShubhamKPBoss
Copy link

Hello, can you please identify Where does the uuid come from? <a:MessageID>uuid:a277f13a-ecae-4492-9d6a-218982122d4c</a:MessageID>

@lindseysimple
Copy link

@ShubhamKPBoss This issue has been closed and is not active. If you have any question for the issue assignee or reporter, please send an email to them directly, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hikvision Hikvision camera question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants