yingchengpa / python-onvif2-zeep

onvif2-zeep support media2 ,for example get the 'h265'(hevc) encoding
MIT License
19 stars 10 forks source link

HTTP Bad Response 400 #2

Open PsitechShubham opened 2 years ago

PsitechShubham commented 2 years ago

I am workig on ONVIF Camera project and I wanted to use media2 for that. I followed your repo and tried to run the examples with modification for user,pass etc

I am able to communicate to camera, and change dates, etc.

But the pullpoint pull message is giving exception and on deeper analysis - looking at packets in wireshark and log - it is receiving the packet and responding with HTTP 1.1 Bad Response. What is it that I am doing wrong?

I am attaching code/the function which is not working (all others are working) for reference :

    def subEvent(self):
        """
        简单描述了核心逻辑,具体需求时需要再修改
        订阅事件通知,
        采用real-time pull-point Notification interface 模式。 需要启动线程
        资料介绍: http://www.doc88.com/p-381499525793.html
        该模式采用的方式:
        createPullPoint() ---- > ipc
        pullMessagees     ---- > ipc
        ------ http wait n seconds ------
        pullMessagesRespons <--  ipc
        pullMessagees     ---- > ipc
        ------ http wait n seconds ------
        pullMessagesRespons <--  ipc
              ............
        unsubscribe  ---- > ipc
        :return:
        """
        # event 订阅事件
        self.events_service = self.mycam.create_events_service()
        print(self.events_service.GetEventProperties())

        pullpoint = self.mycam.create_pullpoint_service()
        # print(pullpoint)
        # print(type(pullpoint))
        pullpoint = self.mycam.pullpoint.zeep_client.create_service(
             '{http://www.onvif.org/ver10/events/wsdl}PullPointSubscriptionBinding',
             self.mycam.xaddrs['http://www.onvif.org/ver10/events/wsdl/PullPointSubscription'])

        # pullpoint.SetSynchronizationPoint()

        plt = self.events_service.CreatePullPointSubscription()
        print(type(plt))
        st = plt.SubscriptionReference
        print(st)
        pullpoint.SetSynchronizationPoint()

        """模块启动时,自动启动一个线程执行清理"""
        # t1 = threading.Thread(target=_time_task, daemon=True)
        # t1.start()
        ######    _time_task  #######
        while True:
            # try:
                # dt = isodate.Duration(seconds=100)

            # dt = datetime.timedelta(seconds=120)
            # print(type(dt))
            # tz = self.events_service.create_type('PullMessage')
            # print(tz)

            # ts = {'Timeout': '00:00:20' , 'MessageLimit': 10}
            # ts.
            pullmsg = OrderedDict()
            # dt = datetime.timedelta(seconds=20)
            # dt = time(second=20)
            pullmsg['Timeout'] = 'P0Y0M0DT0H2M20S'
            pullmsg['MessageLimit'] = 100
            try:
                pullmess = pullpoint.PullMessages(f"{pullmsg['Timeout']}", f"{pullmsg['MessageLimit']}")
                 # pullmess = pullpoint.PullMessages( 'Timeout' : "00:00:20", 'MessageLimit'=10)
                print("Ijjazat")
                print(pullmess.CurrentTime)
                print(pullmess.TerminationTime)
                for msg in pullmess.NotificationMessage:
                    print("--" ,msg)
            except Exception as e:
                print("00000000", e)
            finally:
                pass

**

pullmess = pullpoint.PullMessages(f"{pullmsg['Timeout']}", f"{pullmsg['MessageLimit']}"

**

This statement is giving exception ( a blank one at that) and debugging the code with pycharm debugger, it shows the Bad Request 400, which I confirmed from wireshark logs.

Any Help will be greatly appreciated. as I am stuck for quite some time now. Let me know if anything else is required.

sandeepy0 commented 5 months ago

Not sure. But, might be due to this issue. https://stackoverflow.com/questions/65530487/get-onvif-events-with-python-from-ip-camera/78328968#78328968