patrickmichalina / onvif-rx

📹 Communicate with ONVIF devices and cameras in server and browser environments.
MIT License
22 stars 11 forks source link

503 service unavailabe - setVideoEncoderConf #31

Closed AlonDaPro closed 3 years ago

AlonDaPro commented 3 years ago

Hello, I'm trying to set the video parameters, I'm using Flir camera, it has onvif. I succeded to recieve the parameters by get function but when i'm trying to update them I get 503 service unavailable error.

The deviceUrl is: http://ip/onvif/device_service I tried also media_service and I get the same error.

1603887874495394042983030042627

What should I do? Thanks.

patrickmichalina commented 3 years ago

@alondapro Hi. I believe this may mean a couple of things:

The most to-spec library I know about can be found at https://sourceforge.net/projects/onvifdm/. I would try their library to see if you can get it to work. If it does, that indicates my library is not accurate.

AlonDaPro commented 3 years ago

@alondapro Hi. I believe this may mean a couple of things:

  • Your device does not support that endpoint.
  • Your device is returning the incorrect HTTP status code when it really means to be a 400 error.
  • The library is not constructing the request correctly (but the http response should but 400, not 503)
  • The values you are using are invalid (but the http response should but 400, not 503)

The most to-spec library I know about can be found at https://sourceforge.net/projects/onvifdm/. I would try their library to see if you can get it to work. If it does, that indicates my library is not accurate.

First of all, thank you very much for your fast answer, I really appreciate it! I installed RTSP camera emulator (happy time soft), I tried to use your library on it and for some reason only the get function worked for me again.. But now when I tried to use the set function I got 400 error like you said I should get: "400 Config Does Not Exist", that's what I got. In the emulator I had to use the '/onvif/media_servce/' path.

I think maybe I am the problem, maybe I have to do something before trying to set the data? I also downloaded the software that you gave me and it worked, I succeeded to set data from it but I need it in my code..

`const device = createManagedDeviceInNode({ deviceUrl: http://192.168.1.200:10000/onvif/media_service, // it works username: username, password: password, });

let config: VideoEncoderConfiguration = {
  Resolution: { Width: 1280, Height: 720 },
  Encoding: VideoEncoding.H264,
  Quality: 4,
  H264: { GovLength: 50, H264Profile: H264Profile.Main },
  RateControl: {
    FrameRateLimit: 30,
    EncodingInterval: 50,
    BitrateLimit: 2048
  },
  Multicast: {
    Address: { Type: IPType.IPv4, IPv4Address: '239.0.1.0' },
    Port: 32002,
    TTL: 2,
    AutoStart: false
  },
  MPEG4: { GovLength: 50, Mpeg4Profile: Mpeg4Profile.SP },
  SessionTimeout: 'PT10S'
}

let setData = await device.api.Media.SetVideoEncoderConfiguration(config, true).toPromise();
console.log(setData.match({
  ok: success => { console.log(success.json) },
  fail: failure => { console.log(failure.status, failure.statusMessage) }
}));

let getData = await device.api.Media.GetVideoEncoderConfigurations().toPromise();
console.log(getData.match({
  ok: success => { console.log(success.json.Configurations[0]) },
  fail: failure => { console.log(failure.status, failure.statusMessage) }
}));`

This is my whole code, maybe I forgot something that I have to do? Do you have maybe an example code for how to use the setVideoEncoderConfigurations function?

Thanks again, Alon.

AlonDaPro commented 3 years ago

Hey, I solved the problem before time ago.. also this problem showed in the original ONVIF library. I used XML beautifier on the XML that we were sending before sending it, also in the media section I must give all the parameters. Thanks.