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

jaxws uses ip, instead of DNS #21

Open
RobinGoussey opened this issue Apr 2, 2021 · 3 comments
Open

jaxws uses ip, instead of DNS #21

RobinGoussey opened this issue Apr 2, 2021 · 3 comments

Comments

@RobinGoussey
Copy link

Hi,

I am using this library, to try and connect to cameras, that are behind reverse proxies. However it seems somewhere in the code it changes the camera.localhost to the effective ip address (as in the ip of the camera, not how you connect to it), and that ip is unreachable. So the eg, I use the host https://camera.localhost, and I create an OnvifDevice, but it fails whenever I try and use a service, like media or ptz, since it somehow resolves to a.b.c.d/onvif/media_service, but this I cannot reach (reverse proxy).

Is there a way to trigger all services of Onvif device to keep using the dns instead of the ip of the interface where the camera runs?

@fpompermaier
Copy link
Owner

Unfortunately I dind't wrote this module, I just ported the original version under a more maintainable maven project.
If you have time to dig into this I can merge your PR and release a new version

@RobinGoussey
Copy link
Author

Funny, I just solved it. I tried it before, but intellij did not seem to pick up my code changes. The library uses the xaddr the server gives it, so that being the XAddr. However this is the actual ip address of the service, and not however you reach it.

I solved it by doing this:

In OnvifDevice init, this code needs to be replaced, more specifically (for each service):

getServiceProxy((BindingProvider) media, capabilities.getMedia().getXAddr())
              .create(Media.class)
              //Add this:
getServiceProxy((BindingProvider) media, capabilities.getMedia().getXAddr().replaceFirst("http(s)?://[0-9\\.]+",this.url.toString()))
              .create(Media.class)
    if (capabilities.getMedia() != null && capabilities.getMedia().getXAddr() != null) {
      this.media = new MediaService().getMediaPort();
      this.media =
          getServiceProxy((BindingProvider) media, capabilities.getMedia().getXAddr().replaceFirst("http(s)?://[0-9\\.]+",this.url.toString()))
              .create(Media.class);
    }

    if (capabilities.getPTZ() != null && capabilities.getPTZ().getXAddr() != null) {
      this.ptz = new PtzService().getPtzPort();
      this.ptz =
          getServiceProxy((BindingProvider) ptz, capabilities.getPTZ().getXAddr().replaceFirst("http(s)?://[0-9\\.]+",this.url.toString()))
              .create(PTZ.class);
    }

    if (capabilities.getImaging() != null && capabilities.getImaging().getXAddr() != null) {
      this.imaging = new ImagingService().getImagingPort();
      this.imaging =
          getServiceProxy((BindingProvider) imaging, capabilities.getImaging().getXAddr().replaceFirst("http(s)?://[0-9\\.]+",this.url.toString()))
              .create(ImagingPort.class);
    }

    if (capabilities.getEvents() != null && capabilities.getEvents().getXAddr() != null) {
      this.events = new EventService().getEventPort();
      this.events =
          getServiceProxy((BindingProvider) events, capabilities.getEvents().getXAddr().replaceFirst("http(s)?://[0-9\\.]+",this.url.toString()))
              .create(EventPortType.class);
    }
  }

I'll look into making a pr and uploading it.

@fpompermaier
Copy link
Owner

That would be great!

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