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

2000) failed. Not Connected #3

Open
winkmichael opened this issue Dec 14, 2024 · 14 comments
Open

2000) failed. Not Connected #3

winkmichael opened this issue Dec 14, 2024 · 14 comments

Comments

@winkmichael
Copy link

I’ve been trying to write a Python ONVIF program to control a couple of neighborhood cameras and ended up writing a wayyy less cool version of the program you have here! More to the point, my version doesn’t work with any of my cameras—no matter what I tried, I couldn’t get anywhere with ONVIF beyond basic queries. Looking forward to exporing CherryPy, never heard of it but your code looks clean.

That said, I’m running into the same error on four different cameras, same ones I've been trying to write my program using. Do I have bunk onvif? These cameras work with several VMS systems, both corp and consumer level without complaining at all.

Below is what I am getting from your system. The cameras are online and reachable, they listen on 80, 443 and one 8999 too which is supposed to be the dedicated onvif port but 443 works too.
Any thoughts, suggestions or help would be much appreciated, as I'm really hoping you can help so I can just use your program! (:

2024-12-13 19:33:54 - INFO :: CameraInit-PTZCam2 : Initialization for Camera PTZCam2 at ('192.168.1.220', 2000) failed. Not Connected
2024-12-13 19:33:54 - INFO :: CameraInit-hut2 : Initialization for Camera hut2 at ('192.168.1.83', 2000) failed. Not Connected
2024-12-13 19:33:54 - INFO :: CameraInit-tally : Initialization for Camera tally at ('192.168.1.229', 2000) failed. Not Connected
2024-12-13 19:33:55 - DEBUG :: CameraInit-camera1 : Camera camera1: Getting video source configurations
2024-12-13 19:33:55 - INFO :: CameraInit-camera1 : Initialization for Camera camera1 at ('192.168.1.81', 80) failed. Not Connected

@zSeriesGuy
Copy link
Owner

You indicates the dedicated onvif port is 8999. Update the ptzcontroller.conf option from 2000 to 8999.

@winkmichael
Copy link
Author

Ouch long day for me! I'm not sure how I missed that, but sadly I am closer but still hung up. I am getting a bit more success, I tried all four cameras on 80,443 and 8999 and got something positive on two cameras followed by a disconnect. When I run program, for all the cameras I get of course the cameras are not connected

2024-12-13 20:26:45 - INFO :: MainThread : PTZController Initialization Complete
2024-12-13 20:26:45 - INFO :: CameraInit-PTZCam2 : Initialization for Camera PTZCam2 at ('192.168.1.220', 80) failed. Not Connected
2024-12-13 20:26:46 - INFO :: CameraInit-tally : Initialization for Camera tally at ('192.168.1.229', 80) failed. Not Connected
2024-12-13 20:26:47 - DEBUG :: CameraInit-camera1 : Camera camera1: Getting video source configurations
2024-12-13 20:26:47 - INFO :: CameraInit-camera1 : Initialization for Camera camera1 at ('192.168.1.81', 80) failed. Not Connected
2024-12-13 20:26:47 - DEBUG :: CameraInit-hut2 : Camera hut2: Getting video source configurations
2024-12-13 20:26:48 - INFO :: CameraInit-hut2 : Initialization for Camera hut2 at ('192.168.1.83', 80) failed. Not Connected

2024-12-13 20:28:30 - DEBUG :: CP Server Thread-7 : Control Request: stop ['camera=2']
2024-12-13 20:28:30 - DEBUG :: CP Server Thread-7 : Camera hut2 is not connected.
2024-12-13 20:28:30 - DEBUG :: CP Server Thread-8 : Control Request: move ['pan=-0.5', 'camera=2']
2024-12-13 20:28:30 - DEBUG :: CP Server Thread-8 : Camera hut2 is not connected.
2024-12-13 20:28:30 - DEBUG :: CP Server Thread-9 : Control Request: stop ['camera=2']
2024-12-13 20:28:30 - DEBUG :: CP Server Thread-9 : Camera hut2 is not connected.

Additional suggestions are very much appreciated!

@zSeriesGuy
Copy link
Owner

The 80 after your device ip address indicates you are specifying port 80. Is that the dedicate onvif port?

@zSeriesGuy
Copy link
Owner

Are the cameras on the same network as the computer you are running this program on?
Are they ptz cameras?

@winkmichael
Copy link
Author

These two are cameras fully PTZ capable. I madea little program that queries the onvif cameras and it produces this;

2024-12-13 20:26:46 - INFO :: CameraInit-tally : Initialization for Camera tally at ('192.168.1.229', 80) failed. Not Connected
2024-12-13 20:26:47 - DEBUG :: CameraInit-camera1 : Camera camera1: Getting video source configurations
2024-12-13 20:26:47 - INFO :: CameraInit-camera1 : Initialization for Camera camera1 at ('192.168.1.81', 80) failed. Not Connected
2024-12-13 20:26:47 - DEBUG :: CameraInit-hut2 : Camera hut2: Getting video source configurations

Device Information: {
'Manufacturer': 'ONVIF_ICAMERA',
'Model': 'PTZ-2504X-I2_AF',
'FirmwareVersion': 'V3.0.4.1 build 2021-03-27 15:10:37 \n',
'SerialNumber': 'EF00000000915A60',
'HardwareId': '1419d68a-1dd2-11b2-a105-F00000915A60'
}
Users: [{
'Username': 'admin',
'Password': None,
'UserLevel': 'Administrator',
'Extension': None,
'_attr_1': None
}, {
'Username': 'viewer',
'Password': None,
'UserLevel': 'Administrator',
'Extension': None,
'_attr_1': None
}]
Network Interfaces: [{
'Enabled': True,
'Info': {
'Name': 'eth0',
'HwAddress': 'F0:00:00:91:5A:60',
'MTU': None
},
'Link': None,
'IPv4': {
'Enabled': True,
'Config': {
'Manual': [
{
'Address': '192.168.1.81',
'PrefixLength': 24
}
],
'LinkLocal': None,
'FromDHCP': None,
'DHCP': False,
'_value_1': None,
'_attr_1': None
}
},
'IPv6': None,
'Extension': None,
'token': 'eth0',
'_attr_1': {
}
}]
Network Protocols: [{
'Name': 'HTTP',
'Enabled': True,
'Port': [
80
],
'Extension': None,
'_attr_1': None
}, {
'Name': 'RTSP',
'Enabled': True,
'Port': [
554
],
'Extension': None,
'_attr_1': None
}]
Discovery Mode: Discoverable
Hostname: {
'FromDHCP': False,
'Name': 'IPNC',
'Extension': None,
'_attr_1': None
}
DNS: {
'FromDHCP': False,
'SearchDomain': [
'ipnc'
],
'DNSFromDHCP': [],
'DNSManual': [
{
'Type': 'IPv4',
'IPv4Address': '192.168.1.1',
'IPv6Address': None
}
],
'Extension': None,
'_attr_1': None
}
NTP: {
'FromDHCP': False,
'NTPFromDHCP': [],
'NTPManual': [
{
'Type': 'DNS',
'IPv4Address': None,
'IPv6Address': None,
'DNSname': 'time.windows.com',
'Extension': None,
'_attr_1': None
}
],
'Extension': None,
'_attr_1': None
}
Dynamic DNS call failed
Profiles: [{
'Name': 'MainStream',
'VideoSourceConfiguration': {
'Name': 'VideoSourceMain',
'UseCount': 2,
'SourceToken': 'VideoSourceMain',
'Bounds': {
'x': 0,
'y': 0,
'width': 2560,
'height': 1440
},
'_value_1': None,
'Extension': None,
'token': 'VideoSourceMain',
'_attr_1': {
}
},
'AudioSourceConfiguration': {
'Name': 'AudioMainName',
'UseCount': 2,
'SourceToken': 'AudioMainSrcToken',
'_value_1': None,
'token': 'AudioMainToken',
'_attr_1': {
}
},
'VideoEncoderConfiguration': {
'Name': 'VideoEncodeMain',
'UseCount': 1,
'Encoding': 'H264',
'Resolution': {
'Width': 2560,
'Height': 1440
},
'Quality': 50.0,
'RateControl': {
'FrameRateLimit': 13,
'EncodingInterval': 1,
'BitrateLimit': 3500
},
'MPEG4': {
'GovLength': 0,
'Mpeg4Profile': 'SP'
},
'H264': {
'GovLength': 52,
'H264Profile': 'High'
},
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.1.81',
'IPv6Address': None
},
'Port': 0,
'TTL': 0,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=720),
'_value_1': None,
'token': 'VideoEncodeMain',
'_attr_1': {
}
},
'AudioEncoderConfiguration': {
'Name': 'AudioMain',
'UseCount': 2,
'Encoding': 'G711',
'Bitrate': 64000,
'SampleRate': 8000,
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.1.81',
'IPv6Address': None
},
'Port': 80,
'TTL': 1,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(microseconds=60000),
'_value_1': None,
'token': 'G711',
'_attr_1': {
}
},
'VideoAnalyticsConfiguration': {
'Name': 'VideoAnalyticsName',
'UseCount': 3,
'AnalyticsEngineConfiguration': {
'AnalyticsModule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'Sensitivity',
'Value': '3'
}
],
'ElementItem': [
{
'_value_1': <Element {http://www.onvif.org/ver10/schema}CellLayout at 0x7f92d4700b40>,
'Name': 'Layout'
}
],
'Extension': None,
'_attr_1': None
},
'Name': 'MyCellMotionModule',
'Type': 'tt:CellMotionEngine'
}
],
'Extension': None,
'_attr_1': None
},
'RuleEngineConfiguration': {
'Rule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'MinCount',
'Value': '5'
},
{
'Name': 'AlarmOnDelay',
'Value': '100'
},
{
'Name': 'AlarmOffDelay',
'Value': '100'
},
{
'Name': 'ActiveCells',
'Value': '0P8A8A=='
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Name': 'MyMotionDetectorRule',
'Type': 'tt:CellMotionDetector'
}
],
'Extension': None,
'_attr_1': None
},
'_value_1': None,
'token': 'VideoAnalyticsToken',
'_attr_1': {
}
},
'PTZConfiguration': {
'Name': 'ptz0',
'UseCount': 2,
'NodeToken': 'ptz0',
'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 1.0,
'y': 1.0,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': {
'x': 1.0,
'space': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace'
}
},
'DefaultPTZTimeout': datetime.timedelta(seconds=60),
'PanTiltLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
},
'YRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'ZoomLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'Extension': None,
'token': 'ptz0',
'_attr_1': {
}
},
'MetadataConfiguration': None,
'Extension': None,
'token': 'MainStream',
'fixed': False,
'_attr_1': {
}
}, {
'Name': 'SubStream',
'VideoSourceConfiguration': {
'Name': 'VideoSourceMain',
'UseCount': 2,
'SourceToken': 'VideoSourceMain',
'Bounds': {
'x': 0,
'y': 0,
'width': 704,
'height': 480
},
'_value_1': None,
'Extension': None,
'token': 'VideoSourceMain',
'_attr_1': {
}
},
'AudioSourceConfiguration': {
'Name': 'AudioMainName',
'UseCount': 2,
'SourceToken': 'AudioMainSrcToken',
'_value_1': None,
'token': 'AudioMainToken',
'_attr_1': {
}
},
'VideoEncoderConfiguration': {
'Name': 'VideoEncodeSub',
'UseCount': 1,
'Encoding': 'H264',
'Resolution': {
'Width': 704,
'Height': 480
},
'Quality': 50.0,
'RateControl': {
'FrameRateLimit': 25,
'EncodingInterval': 1,
'BitrateLimit': 2048
},
'MPEG4': {
'GovLength': 0,
'Mpeg4Profile': 'SP'
},
'H264': {
'GovLength': 52,
'H264Profile': 'High'
},
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.1.81',
'IPv6Address': None
},
'Port': 0,
'TTL': 0,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(seconds=720),
'_value_1': None,
'token': 'VideoEncodeSub',
'_attr_1': {
}
},
'AudioEncoderConfiguration': {
'Name': 'AudioMain',
'UseCount': 2,
'Encoding': 'G711',
'Bitrate': 64000,
'SampleRate': 8000,
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.1.81',
'IPv6Address': None
},
'Port': 80,
'TTL': 1,
'AutoStart': False,
'_value_1': None,
'_attr_1': None
},
'SessionTimeout': datetime.timedelta(microseconds=60000),
'_value_1': None,
'token': 'G711',
'_attr_1': {
}
},
'VideoAnalyticsConfiguration': {
'Name': 'VideoAnalyticsName',
'UseCount': 3,
'AnalyticsEngineConfiguration': {
'AnalyticsModule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'Sensitivity',
'Value': '80'
}
],
'ElementItem': [
{
'_value_1': <Element {http://www.onvif.org/ver10/schema}CellLayout at 0x7f92d470e300>,
'Name': 'Layout'
}
],
'Extension': None,
'_attr_1': None
},
'Name': 'MyCellMotionModule',
'Type': 'tt:CellMotionEngine'
}
],
'Extension': None,
'_attr_1': None
},
'RuleEngineConfiguration': {
'Rule': [
{
'Parameters': {
'SimpleItem': [
{
'Name': 'MinCount',
'Value': '5'
},
{
'Name': 'AlarmOnDelay',
'Value': '100'
},
{
'Name': 'AlarmOffDelay',
'Value': '100'
},
{
'Name': 'ActiveCells',
'Value': '0P8A8A=='
}
],
'ElementItem': [],
'Extension': None,
'_attr_1': None
},
'Name': 'MyMotionDetectorRule',
'Type': 'tt:CellMotionDetector'
}
],
'Extension': None,
'_attr_1': None
},
'_value_1': None,
'token': 'VideoAnalyticsToken',
'_attr_1': {
}
},
'PTZConfiguration': {
'Name': 'ptz0',
'UseCount': 2,
'NodeToken': 'ptz0',
'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace',
'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 1.0,
'y': 1.0,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': {
'x': 1.0,
'space': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace'
}
},
'DefaultPTZTimeout': datetime.timedelta(seconds=60),
'PanTiltLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
},
'YRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'ZoomLimits': {
'Range': {
'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'XRange': {
'Min': -1.0,
'Max': 1.0
}
}
},
'Extension': None,
'token': 'ptz0',
'_attr_1': {
}
},
'MetadataConfiguration': None,
'Extension': None,
'token': 'SubStream',
'fixed': False,
'_attr_1': {
}
}]
Profile: MainStream Stream URI: rtsp://192.168.1.81:554/stream0?username=admin&password=291EB02F60D57B265393F665CEB8B334
Profile: SubStream Stream URI: rtsp://192.168.1.81:554/stream1?username=admin&password=291EB02F60D57B265393F665CEB8B334

@winkmichael
Copy link
Author

Appologizes that copy paste got away on me. Long story short yes I believe this should be all good, as I mentioned, I am currently using these onvif cameras with couple video management systems via the onvif classification. One is HikVision, the other a very generic chinese rushed type ip camera.

@zSeriesGuy
Copy link
Owner

In the Network Protocols section, it lists the HTTP and the RTSP ports, but not onvif. I don't know if onvif has to be enabled in the camera configuration. But take a look to make sure onvif is enabled and note what the port us.
For my code to work, youMUST specify the onvif port, NOT the http port

@zSeriesGuy
Copy link
Owner

I found a little more information about Hikvision cameras. Seems you are correct in using port 80.
In the camera configuration is an advanced settings where the enable onvif checkbook is.
I'm guessing you already have that enabled. Below that is where you can create user and password. Try using that userid and password in the ptzcontroller.conf settings. Other than that, I'm at a loss.

@zSeriesGuy
Copy link
Owner

One last idea.
I noticed in your paste that the password for admin and viewer users is None. My code probably does not handle that correctly. Try setting a password in your camera configuration and put that in the ptzcontroller.conf. if that fixes it, let me know and I'll fix my code.

@winkmichael
Copy link
Author

Thanks for helping me out tonight. I've check the cameras over again and tried some others cameras and all of them are actively running with QNAP Survellance system setup in ONVIF mode. Somehow or another all running Onvif mode - part of me is getting crazy saying well maybe I'm causing a collision because the QNAP archiver is running at the same time? lol I know its not that but getting crazy (;

I'm curious what cameras you are using and tested against, all of mine are low end cameras, with HIKVision being the best.

Here is the config I have for the 4 cameras at the moment

[DEFAULT]
power_on = no
power_off = no

[General]
log_dir = None
launch_browser = no

[Webserver]
server_port = 8080
remote = yes

[camera1]
host = 192.168.1.81
port = 80
userid = admin
password = prados123
port_visca = 1259
power_on = no
power_off = no

[hut2]
host = 192.168.1.83
port = 80
userid = admin
password = prados123

[Camera2]
host = 192.168.1.220
port = 80
userid =
password =
name = PTZCam2

[post]
host = 192.168.1.229
port = 8000
userid = boogers11
password = Boogers11
name = post-tall

@zSeriesGuy
Copy link
Owner

Is the computer you are running my code on on the same 192.168.1.x network?
I recently tested my code on a remote camera attempting to access it thru a forwarded port. It did not work and gave me the connection failed message. I have not attempted yet to come up with a solution.

@zSeriesGuy
Copy link
Owner

I guess I need to add more diagnostics to my code to try to identify what caused the connection failure.

@winkmichael
Copy link
Author

Is the computer you are running my code on on the same 192.168.1.x network? I recently tested my code on a remote camera attempting to access it thru a forwarded port. It did not work and gave me the connection failed message. I have not attempted yet to come up with a solution.

Currently on different subnets but fully routable, no firewall between them and proxy_arp enabled. So basically yup, same networks.

@zSeriesGuy
Copy link
Owner

Can you try this?

Edit camera.py
add import traceback up at the top
in the except handling in the __initialize block, add print(traceback.format_exc())

This might tell us where it is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants