mirthas / fritztr064 Goto Github PK
View Code? Open in Web Editor NEWJava API for the Fritzbox TR-064 protokoll
License: Apache License 2.0
Java API for the Fritzbox TR-064 protokoll
License: Apache License 2.0
I'm trying to connec to my fritzbox 7490 but the init() method arise a NullPointerException
I'm testing with the example code:
FritzConnection fc = new FritzConnection("192.168.178.1","test_usr","test_psw");
fc.init();
fc.printInfo();
Exception retrived:
Exception in thread "main" java.lang.NullPointerException
at de.mapoll.javaAVMTR064.FritzConnection.readIGDDESC(FritzConnection.java:138)
at de.mapoll.javaAVMTR064.FritzConnection.init(FritzConnection.java:120)
If I try to use your library, I only get NullPointerExceptions
. If I use the constructor without credentials in readIGDDESC()
, if I use the constructor with credentials in readTR64()
. In both cases the NPE
happens when calling device.getFriendlyName()
, as the RootType
or RootType2
objects are not populated.
If I use the following code
JAXBContext jaxbContext = JAXBContext.newInstance(RootType.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
// the following line is important to get the validation error as Exception,
// otherwise the error is simply swallowed
unmarshaller.setEventHandler(event -> false);
unmarshaller.unmarshal(new URL("http://fritz.box:49000/tr64desc.xml"));
I get the exception
Exception in thread "main" javax.xml.bind.UnmarshalException: unerwartetes Element (URI:"urn:dslforum-org:device-1-0", lokal:"major"). Erwartete Elemente sind <{}minor>,<{}major>
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:247)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:242)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:109)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:90)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:237)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:556)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:538)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:153)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:221)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:276)
at my class
This happens because your JaxBs only have the namespace for the root element, but the actual XML files delivered by FRITZ!Box have the default namespace set and thus all elements have that namespace.
Leider schlägt die Authentifizierung mit der FB fehl.
FB Login aktuell mit Passwort (Macht keinen Unterschied ob nur PW oder PW+User)
Beim versuch des Verbindungsaufbaus bekommt man jedoch eine 401 Antwort von der FB.
`
Service service = fritzConnection.getService("X_AVM-DE_OnTel:1");
Action action = service.getAction("GetPhonebookList");
try {
Response response = action.execute();
System.out.println(response.getData());
} catch (IOException e) {
logger.error("IO Fehler", e);
}
`
Löst folgende Exception aus
java.io.IOException: HTTP/1.1 401 Unauthorized at de.mapoll.javaAVMTR064.FritzConnection.httpRequest(FritzConnection.java:167) at de.mapoll.javaAVMTR064.FritzConnection.getSOAPXMLIS(FritzConnection.java:192) at de.mapoll.javaAVMTR064.Action.execute(Action.java:185) at de.mapoll.javaAVMTR064.Action.execute(Action.java:131)
Sobald der Login auf der FB deaktiviert wird, funktioniert alles Problemlos. Dies kann jedoch kein Zustand sein. Verständlicherweise.
I basically followed the example of listing all wlan devices.
My Fritzbox (FRITZ!Box Fon WLAN 7390) returns me 8 "NewTotalAssociations".
When going through thes Assocuations I get the following results:
after debugging into it, I found out that in the class FritzConnection the process hangs in the function getSOAPXMLIS at the line "CloseableHttpResponse response = httpClient.execute(targetHost, httppost, context);"
it never returns from this line.
I am using httpcomponent-client-4.4.1
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.