HomeX-It / pusher-websocket-flutter

An unofficial Flutter plugin that wraps pusher-websocket-java on Android and pusher-websocket-swift on iOS
MIT License
30 stars 22 forks source link

FileNotFoundException on subscribing to private channel #22

Open rvamsikrishna opened 4 years ago

rvamsikrishna commented 4 years ago

Hello, thank you very much for this package. I am successfully able to subscribe to the public channels and receive events that are sent from the pusher debug console. The exception is thrown when I am trying to subscribe to private channels. I have in the backend written in laravel. I'm not a back end developer so I could not debug if the problem is on the back end.

I pass the required auth endpoint and also the request headers to PusherAuth. When I try to connect to the pusher cancel and subscribe to a private channel I get this file not found exception which points to the auth endpoint URL as below

D/PusherPlugin( 8418): onCancel args: null
D/PusherPlugin( 8418): init
D/PusherPlugin( 8418): connect
D/PusherPlugin( 8418): subscribe (private)
D/PusherPlugin( 8418): bind (BroadcastNotificationCreated)
I/flutter ( 8418): CONNECTING
I/flutter ( 8418): CONNECTED
D/PusherPlugin( 8418): onError : java.io.FileNotFoundException: https://<my-url>/broadcasting/auth
W/System.err( 8418): com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: https://<my-url>/broadcasting/auth
W/System.err( 8418):    at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:146)
W/System.err( 8418):    at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:127)
W/System.err( 8418):    at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90)
W/System.err( 8418):    at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:140)
W/System.err( 8418):    at com.pusher.client.util.Factory$1.run(Factory.java:109)
W/System.err( 8418):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err( 8418):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err( 8418):    at java.lang.Thread.run(Thread.java:764)
W/System.err( 8418): Caused by: java.io.FileNotFoundException: https://<my-url>/broadcasting/auth
W/System.err( 8418):    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
W/System.err( 8418):    at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
W/System.err( 8418):    at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(Unknown Source:0)
W/System.err( 8418):    at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128)
W/System.err( 8418):    ... 7 more
I/flutter ( 8418): java.io.FileNotFoundException: https://<my-url>/broadcasting/auth
W/OkHttpClient( 8418): A connection to <my-url> was leaked. Did you forget to close a response body?

I cannot add the real URL above in the logs so added . The laravel code does not have any auth endpoint set, so according to the laravel docs the default is /broadcasting/auth. Any help is appreciated.

jinseokoh commented 4 years ago

It did look to me like your Pusher.init('...', PusherOptions(auth: PusherAuth('url', headers: {}), cluster: 'ap3'), enableLogging: true) setting is not quite right at the moment.

As the following error indicates that your current config does not have a proper url value

D/PusherPlugin( 8418): onError : java.io.FileNotFoundException: https://<my-url>/broadcasting/auth
rvamsikrishna commented 4 years ago

@jinseokoh So its a problem with setting a right auth endpoint?

jinseokoh commented 4 years ago

@rvamsikrishna As I haven't experienced such error with this package, probably your current private auth setting is not correct. Check out the example code in the following PR. Hope you find it useful.

https://github.com/kakajansh/echo/pull/24
DeepakPant commented 4 years ago

W/System.err(20778): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(20778): at java.lang.Thread.run(Thread.java:919) W/System.err(20778): Caused by: java.io.FileNotFoundException: https://meroswasthya.org/broadcasting/auth W/System.err(20778): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:259) W/System.err(20778): at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211) W/System.err(20778): at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30) W/System.err(20778): at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128) W/System.err(20778): ... 7 more I/flutter (20778): Error: java.io.FileNotFoundException: https://ysite.org/broadcasting/auth Channel error

I have similar issue . Is your issue fixed? Public channel works fine something is not correct with authorization pusher