pusher_client
pusher_client copied to clipboard
cant't change PusherAuth
My application uses JWT Token, and it’s only valid for five minutes.
But now I cannot change the Auth setting of Pusher
Hello. I have the same problem. My app to changes token after every login. I should change auth token after re-login app. But now I have exception when subscribe to private channel again. I think pusherClient or channel instance still save old pusher connect. @chinloyal please help
E/PusherClientPlugin(13836): java.io.FileNotFoundException: https://<url>/pusher/auth W/System.err(13836): com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: https://<url>pusher/auth W/System.err(13836): at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:146) W/System.err(13836): at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130) W/System.err(13836): at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90) W/System.err(13836): at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149) W/System.err(13836): at com.pusher.client.util.Factory$1.run(Factory.java:119) W/System.err(13836): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(13836): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(13836): at java.lang.Thread.run(Thread.java:923) W/System.err(13836): Caused by: java.io.FileNotFoundException: https://<url>/pusher/auth W/System.err(13836): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255) W/System.err(13836): at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211) W/System.err(13836): at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30) W/System.err(13836): at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128) W/System.err(13836): ... 7 more E/PusherClientPlugin(13836): java.io.FileNotFoundException: https://<url>/pusher/auth W/System.err(13836): com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: https://<url>/pusher/auth W/System.err(13836): at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:146) W/System.err(13836): at com.pusher.client.channel.impl.PrivateChannelImpl.getAuthResponse(PrivateChannelImpl.java:130) W/System.err(13836): at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:90) W/System.err(13836): at com.pusher.client.channel.impl.ChannelManager$1.run(ChannelManager.java:149) W/System.err(13836): at com.pusher.client.util.Factory$1.run(Factory.java:119) W/System.err(13836): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(13836): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(13836): at java.lang.Thread.run(Thread.java:923) W/System.err(13836): Caused by: java.io.FileNotFoundException: https://<url>/pusher/auth W/System.err(13836): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255) W/System.err(13836): at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211) W/System.err(13836): at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30) W/System.err(13836): at com.pusher.client.util.HttpAuthorizer.authorize(HttpAuthorizer.java:128)
@chinloyal
I am having the same problem in my Flutter app. @chinloyal
Did anyone solve this issue?
I was able to resolve this issue, and if anybody needs a version that allows you to change PusherAuth on new login etc. you can use my fork of this repo (its null-safety): https://github.com/jeghedderchristoffer/pusher_client. I do not think this library is maintained anymore so forking is your best opportunity. Cheers!
@cjo4m06 Maybe I'm misinterpreting what you're saying but you can set the auth on PushOptions
object using a PusherAuth
object
@chinloyal Please check this.
PusherOptions options = PusherOptions(
host: AppConstants.PUSHER_HOST,
wssPort: AppConstants.PUSHER_WSS_PORT,
encrypted: true,
auth: PusherAuth(
AppConstants.API_BASE_URL + _authUrl,
headers: {
'Content-type': 'application/json',
'Authorization':
'Bearer ${_box.read(AppConstants.TOKEN_KEY) ?? null}',
'Device-Info': deviceInfo,
},
),
);
Now when the token changes, PusherAuth
isn't picking up the new token. It still uses the old token and the connection keeps failing. I hope this explanation will help you in debugging.
I have the same issue. I Have to close the app and restart it before it works but it is not a good experience for final users.