Re: Problem using WebDetector in default-foreign-source.xml
Jonathan Heard <[email protected]>
| Newsgroups | gmane.network.opennms.general |
|---|---|
| Message-ID | <[email protected]> |
Hi John,   From what I can discern via a quick search of the code, WebDetector uses opennms/core/web/HttpClientWrapper.java which in turn uses the Apache HttpClient library, and this does appear to follow redirects by default. Based on the examples shown on this blog http://www.baeldung.com/httpclient-stop-follow-redirect I can't see anywhere in OpenNMS's wrapper that disables or allows you to disable redirection. I think this would be an ideal feature to have in a detector but I'm 50/50 on whether this is a bug or a feature request as following redirects is generally a reasonable thing for the detector to do. Either way I think you should probably raise is as an issue. Interestingly there's an old (and seemingly unresolved) issue that HttpMonitor doesn't follow redirects: https://issues.opennms.org/browse/NMS-5338 Based on this quick look, I reckon that the feature could be relatively easily implemented by adding a method to HttpClientWrapper which allows setting of a followRedirects boolean, and expose it via the WebDetector class too. In this particular case, you could possible use HttpDetector instead but this only allows you to set maxRetCode which is a bit restrictive, but if you set it to 200 then there only appears to be four 1xx codes which are all a bit obscure; https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_Informational_responses HTH Jonathan On 19/04/18 04:18, JohnD Blackburn wrote: > > Hi All, > > I’ve come across an issue with setting up a web detector. > > I’ve added the following to default-foreign-source.xml > > <detector name="RFINTEG-logcall" > class="org.opennms.netmgt.provision.detector.web.WebDetector"> > > <parameter key="port" value="80"/> > > <parameter key="responseRange" value="200-200"/> > > <parameter key="timeout" value="10000"/> > > <parameter key="path" value="/cgi-bin/logcall.pl"/> > > </detector> > > And this is working and correctly detecting that URI on the server > that is supposed to be serving that. However, there is another server > that automatically redirects all calls to non-existent URI’s to > /users/signin/ > > If I perform a curl on http://wrongserver/cgi-bin/logcall.pl I see the > return code of 302 with a reference to /users/signin/ > > And of course running curl against http://wrongserver/users/signin/ is > giving a return code of 200. > > In the foreign source detector, I set the response range to only > accept 200 as valid code thinking that it would exclude the 302, but > it appears that the WebDetector is following the 302 redirect and > using the response code of the re-directed URI, so is therefore > incorrectly detecting this URI where it should not. > > How do I stop the detector from following the redirect, and only > detecting the URI if there is no re-direct?  In this case, if I get a > 302, then this is not the web server I am looking for… > > Regards, > > John Blackburn > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > Please read the OpenNMS Mailing List FAQ: > http://www.opennms.org/index.php/Mailing_List_FAQ > > opennms-discuss mailing list > > To *unsubscribe* or change your subscription options, see the bottom of this page: > https://lists.sourceforge.net/lists/listinfo/opennms-discuss ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-discuss mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-discuss