我试图从onvif设备获取实时流我的程序搜索并成功找到摄像机IP和onvif端口,但在下一步获取设备信息我面临此错误:
没有端点侦听http://192.168.1.89/onvif/device_service可以接受该消息。这通常是由不正确的地址或SOAP操作引起的。
我不知道我的代码有什么问题,即使我想从设备中获取时间和日期也有同样的错误! 我的代码是:
private Device deviceChannel = null;
private System.ServiceModel.Channels.Binding binding = null;
private string serverNetworkAddress;
private string serviceAddress;
private string serverUsername = "";
private string serverPassword = "";
InitializeComponent();
serverUsername = OnvifUserTextBox.Text;
serverPassword = OnvifPwdTextBox.Text;
serverNetworkAddress = serverAddrTextBox.Text;
serviceAddress = string.Format("http://{0}/onvif/device_service", serverNetworkAddress);
//Create Binding
binding = CreateBinding();
private static System.ServiceModel.Channels.Binding CreateBinding()
{
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
TransportSecurityBindingElement transportSecurity = new TransportSecurityBindingElement();
transportSecurity.EndpointSupportingTokenParameters.SignedEncrypted.Add(
new UsernameTokenParameters());
transportSecurity.AllowInsecureTransport = true;
transportSecurity.IncludeTimestamp = false;
TextMessageEncodingBindingElement me =
new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8);
return new CustomBinding(transportSecurity, me, httpTransport);
}
private static TChannel GetChannel<TChannel> (System.ServiceModel.Channels.Binding binding,
string serviceAddressText,
string serverUsername,
string serverPassword)
{
EndpointAddress serviceAddress = new EndpointAddress(serviceAddressText);
ChannelFactory<TChannel> channelFactory =
new ChannelFactory<TChannel>(binding, serviceAddress);
// configure the username credentials on the channel factory
UsernameClientCredentials credentials =
new UsernameClientCredentials(new UsernameInfo(serverUsername, serverPassword));
// replace ClientCredentials with UsernameClientCredentials
channelFactory.Endpoint.Behaviors.Remove(typeof(ClientCredentials));
channelFactory.Endpoint.Behaviors.Add(credentials);
return channelFactory.CreateChannel();
}
private void button2_Click(object sender, EventArgs e)
{
//getting the device information
listBox.Items.Clear();
serverUsername = OnvifUserTextBox.Text;
serverPassword = OnvifPwdTextBox.Text;
serverNetworkAddress = serverAddrTextBox.Text;
serviceAddress = string.Format("http://{0}/onvif/device_service", serverNetworkAddress);
// string model, firmwareVersion, serialNumber, hardwareId;
try
{
// Create a client with given client endpoint configuration
deviceChannel =
GetChannel<Device>(binding, serviceAddress, serverUsername, serverPassword);
// deviceChannel.GetDeviceInformation= ( out model, out FirmwareVersion, out SerialNumber, out HardwareId);
//get date and time
var timemamo = deviceChannel.GetSystemDateAndTime();
listBox.Items.Add(timemamo);
var info = deviceChannel.GetDeviceInformation(new GetDeviceInformationRequest());
//MessageBox.Show(string.Format("Model: {0}", info.Model));
string strManuf = string.Format("Manufacturer: {0}", info.Manufacturer);
listBox.Items.Add(strManuf);
string strModel = string.Format("Model: {0}", info.Model);
listBox.Items.Add(strModel);
string strFw = string.Format("Firmware Version: {0}", info.FirmwareVersion);
listBox.Items.Add(strFw);
string strSerialNo = string.Format("Serial Number: {0}", info.SerialNumber);
listBox.Items.Add(strSerialNo);
string strHwId = string.Format("Hardware Id: {0}", info.HardwareId);
listBox.Items.Add(strHwId);
}
catch (Exception exception)
{
string str = string.Format("GetDeviceInformation():mamo " + exception.Message);
listBox.Items.Add(str);
}
}
答案 0 :(得分:0)
您的Onvif设备可能无法侦听默认端口。尝试将正确的端口号(Onvif端口,而不是HTTP或RTSP)添加到URL,例如:
http://192.168.1.89:8182/onvif/device_service
答案 1 :(得分:0)
使用554端口,它是onvif
中实时流媒体的默认端口答案 2 :(得分:0)
尝试扫描IP摄像机上所有打开的端口。
例如,在UNIX系统中,您可以使用命令nmap -p- 192.168.1.89
。
然后,尝试为所有找到的端口打开相同的路径。在我的相机端口中,端口8999
远非标准,没有-p-
标志就没有出现在快速扫描模式中。