0

I am tying to communicate to the IP camera GUUDGO GD-SC01 using ONVIF protocol. In camera's spec stays about ONVIF support: Support - Upgraded Version from 2017-11-28th I am using the code from

How to discover onvif devices in C#

in order to discover device and find listening URI:

        var endPoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);
        var discoveryClient = new DiscoveryClient(endPoint);
        discoveryClient.FindProgressChanged += discoveryClient_FindProgressChanged;
        FindCriteria findCriteria = new FindCriteria();
        findCriteria.Duration = TimeSpan.MaxValue;
        findCriteria.MaxResults = int.MaxValue;
        findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter", "http://www.onvif.org/ver10/network/wsdl"));
        discoveryClient.FindAsync(findCriteria);

I found in endpoint metadata enter image description here

After that, I tried to use the code from:

https://www.youtube.com/watch?v=mk6vAyIZZ0A&list=PLc2UaWzFQrPN7XNq2mAkVdsMkRCI0BMML&index=2

together with URI:

http://192.168.0.116:5000/onvif/device_service

    deviceUri = new UriBuilder("http://192.168.0.116:5000/onvif/device_service");
        deviceUri.UserName = "admin";
        deviceUri.Password = "6513Enmujnem";
        System.ServiceModel.Channels.Binding binding;
        HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
        httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest;
        binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), httpTransport);
        Device.DeviceClient device = new Device.DeviceClient(binding, new EndpointAddress(deviceUri.ToString()));
        Device.Service[] services = device.GetServices(false);

The last line produces: System.ServiceModel.CommunicationException: 'The underlying connection was closed: The connection was closed unexpectedly.'

Can anybody help me with this problem? What could be the cause of this exception?

I also added tracing possibility, but can't see any useful info about this exception:

System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown
[0]:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
ITAOnvif.Device.Device.GetServices(GetServicesRequest request)

THANKS in advance!

Enmujnem
  • 31
  • 1
  • 3
  • please download wireshark, use it to collect the traffic between you and the camera and add to your question the xml exchanged from the pc to the camera and viceversa. (right click on the packet with the http request and select follow tcp stream. You'll get the exchanged xml text) – Ottavio Campana Aug 18 '20 at 20:28
  • Thanks for the help. It helps me to find the cause of the problem. the problem was that the camera does not support the latest ONVIF standard. I have found happytimesoft ONVIF and RTSP server and tested the code. It worked fine. My advice for the novels (like me): use simulator with proven functionality before trying some unknown device. – Enmujnem Aug 21 '20 at 09:38
  • @Enmujnem I am also trying to follow the same tutorial. However, I have few confusions. How did you install vlc library? Can you please help me with that? – Virtuall.Kingg Apr 12 '22 at 06:54

0 Answers0