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

Server never properly responds #29

Closed
freaktechnik opened this issue Nov 3, 2018 · 5 comments · Fixed by #30
Closed

Server never properly responds #29

freaktechnik opened this issue Nov 3, 2018 · 5 comments · Fixed by #30
Assignees

Comments

@freaktechnik
Copy link
Contributor

Sorry if this isn't actually an issue with this library and I'm just using it wrong - it's been a long time since I've written proper Java.

I've gotten to the point where I can start the web server. Doesn't matter if I start it as daemon or not or what route on the server I load, I always get the following errors for a single request:

E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)
E/fi.iki.elonen.NanoHTTPD: Communication with the client broken, or an bug in the handler code
    java.lang.NullPointerException: Attempt to invoke virtual method 'fi.iki.elonen.NanoHTTPD$Response fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(java.util.Map, fi.iki.elonen.NanoHTTPD$IHTTPSession)' on a null object reference
        at fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
        at fi.iki.elonen.router.RouterNanoHTTPD.serve(RouterNanoHTTPD.java:671)
        at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
        at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
        at java.lang.Thread.run(Thread.java:764)

This is with https://github.com/freaktechnik/Webthingify

Server is started here: https://github.com/freaktechnik/Webthingify/blob/master/app/src/main/java/be/humanoids/webthingify/ServerTask.java
Thing implementation is here: https://github.com/freaktechnik/Webthingify/blob/master/app/src/main/java/be/humanoids/webthingify/Phone.java

(most of the code is just glue between Android and the web thing library)

@mrstegeman
Copy link
Contributor

mrstegeman commented Nov 4, 2018

The server tries to listen on port 80 by default, which isn't allowed by Android. Try listening on a different port. Try something higher, like 8080.

@freaktechnik
Copy link
Contributor Author

freaktechnik commented Nov 4, 2018

I'm passing in 0 and it's choosing a random port number in the unassigned range (5 digits) according to its own reporting. I get the port here: https://github.com/freaktechnik/Webthingify/blob/master/app/src/main/java/be/humanoids/webthingify/ServerTask.java#L32

As I said, this error occurs when actually trying to load a path the server is serving, not in the setup.

@acris5
Copy link

acris5 commented Nov 6, 2018

Also got these errors on android. Thing became available after using real ip of device as hostname
server = new WebThingServer(new WebThingServer.SingleThing(busstop),
8889,ip_current);
But still can't make websockets working to pass events to gateway

@freaktechnik
Copy link
Contributor Author

I figured out that the errors I posted here are happen on endpoints that the server is not explicitly serving.

There's also some issue with org.json from Abdroid not working with this lib.

@acris5
Copy link

acris5 commented Nov 6, 2018

      I figured out that the errors I posted here are happen on endpoints that the server is not explicitly serving.

There's also some issue with org.json from Abdroid not working with this lib.

I do not have this issue, what are you about?

@mrstegeman mrstegeman self-assigned this Nov 6, 2018
@ghost ghost removed the review label Nov 8, 2018
@mrstegeman mrstegeman added this to Done in WebThings Gateway Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

3 participants