Skip to content

TypeError: response.currentTime.getTime is not a function #58

@GrumpyMeow

Description

@GrumpyMeow

Hi,

I just received a new camera which should support Onvif. It does, but initially an error is triggered.
I did some digging around and found a workaround by patching node_modules/onvif/lib/events.js.
Apparently the package "onvif" does not correctly parse the response and not parse date.
This patch worked:

function _terminationTime(response) {
                if (typeof response.currentTime === "string") {
                   response.currentTime = new Date(Date.parse(response.currentTime));
                }    
                if (typeof response.terminationTime === "string") {
                   response.terminationTime = new Date(Date.parse(response.terminationTime));
                }   
                return new Date(Date.now() - response.currentTime.getTime() + response.terminationTime.getTime());
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions