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

Not able to pull messages using PullMessages #121

Open
Itachi-6 opened this issue Feb 4, 2025 · 0 comments
Open

Not able to pull messages using PullMessages #121

Itachi-6 opened this issue Feb 4, 2025 · 0 comments

Comments

@Itachi-6
Copy link

Itachi-6 commented Feb 4, 2025

Hello Team,

I have an ONVIF compliant camera and it generates metadata for each frame. I downloaded the ODM and I was able to see the metadata for each frame on the live feed. The main goal of mine is to download those events in any file format which can be later accessible. I tried several scripts but with no luck. The main error I was getting is with PullMessages, it seems like there is no PullMessages at all. I don't know may be I am doing something wrong. Any help would be much appreciated!!

Note: The metadata generated by my camera is proprietary data but I guess it doesn't matter for ONVIF because if that's the case then, I will not be able to see the metadata in ODM right. So, if I can see the metadata there, then probably I would be able to access them as well.

I see that there are a lot of issues which are unanswered in the "issues" section of this repository. Please I request you to please answer them and for mine as well. If my problem gets solved, I have a little understanding of how things are going with this so, I will also try to answer some questions. Thank you.

One of the scripts which I tried is as follows:

from onvif import ONVIFCamera
import time

# Camera Connection Details
CAMERA_IP = "192.168.1.100"  # Replace with your camera's IP address
PORT = 80  # Default ONVIF port
USERNAME = "admin"  # Replace with your camera's username
PASSWORD = "password"  # Replace with your camera's password
WS_DIR = "/path/to/wsdl"  # Path to ONVIF WSDL files

# Initialize ONVIF Camera
camera = ONVIFCamera(CAMERA_IP, PORT, USERNAME, PASSWORD, wsdl_dir=WS_DIR)

# Create the Event Service
event_service = camera.create_events_service()

# Create PullPoint Subscription
pullpoint = event_service.CreatePullPointSubscription()

# Retrieve the Subscription Reference
subscription_reference = pullpoint.SubscriptionReference

# Create the PullPoint Service
pullpoint_service = camera.create_pullpoint_service()

# Function to Pull and Process Messages
def pull_messages():
    while True:
        try:
            # Set Synchronization Point
            pullpoint_service.SetSynchronizationPoint()

            # Create PullMessages request
            req = pullpoint_service.create_type('PullMessages')
            req.Timeout = 'PT10S'  # Timeout set to 10 seconds
            req.MessageLimit = 10  # Limit to 10 messages per pull

            # Pull messages
            response = pullpoint_service.PullMessages(req)

            # Process received messages
            if response.NotificationMessage:
                for msg in response.NotificationMessage:
                    # Extract and print message details
                    print(f"Message: {msg}")
            else:
                print("No new messages.")

            # Wait before next pull
            time.sleep(5)

        except Exception as e:
            print(f"Error: {e}")
            break

# Start pulling messages
pull_messages()

# Unsubscribe when done
event_service.Unsubscribe()

After running this script the error which I am getting is:

raise exceptions.LookupError(
zeep.exceptions.LookupError: No element 'PullMessages' in namespace http://docs.oasis-open.org/wsrf/rw-2. Available elements are:  -
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

1 participant