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

FileNotFoundException thrown when server responds with 400 or above #261

Open
wardvl opened this issue May 15, 2020 · 0 comments
Open

FileNotFoundException thrown when server responds with 400 or above #261

wardvl opened this issue May 15, 2020 · 0 comments

Comments

@wardvl
Copy link

wardvl commented May 15, 2020

What is the issue?

When the server responds with a HTTP status 400 or above a FileNotFoundException is thrown

Is it a crash report? Submit stack traces or anything that you think would help

com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: http://10.0.2.2:8000/api/device/auth
        at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:146)
        at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130)
        at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90)
        at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149)
        at com.pusher.client.util.Factory$1.run(Factory.java:119)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.io.FileNotFoundException: http://10.0.2.2:8000/api/device/auth
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
        at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128)
        at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130) 
        at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90) 
        at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149) 
        at com.pusher.client.util.Factory$1.run(Factory.java:119) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 

Any improvements you suggest

When a status 400 or above is returned from the server get the errorStream instead of the inputStream.

if (responseStatus >= HTTP_BAD_REQUEST) {
     is = connection.getErrorStream();
} else {
     is = connection.getInputStream();
}

CC @pusher/mobile

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

1 participant