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

com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: #25

Open
godwintrav opened this issue Jun 30, 2021 · 12 comments
Assignees

Comments

@godwintrav
Copy link

Hello I'm trying to authorize my pusher client but I keep getting this error: com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: http://167.99.214.205/api/v1/broadcasting/auth.

Please what can I do?

@chinloyal
Copy link
Owner

Can you share your pusher configuration?

@Djihanegh
Copy link

I have the same problem

Here's my Pusher config :

static PusherClient? pusher;
static Channel? channel;

static Future<void> initPusher(String token, int userId) async {
 PusherOptions options = new PusherOptions(
      cluster: 'eu',
      auth: new PusherAuth(
        'https://url',
        headers: {
          'authentication': '$token',
        },
      ),
    );

    try {
      pusher = new PusherClient("APP_KEY", options,
          enableLogging: true, autoConnect: false);

        pusher?.connect();

     channel = pusher?.subscribe("private-user" + '$userId');

}catch(e) {
}

After hours of debugging i managed that the pusher client is sending the previous token to the server.
(This error only happens when i connect with another account, if it was my first login everything is fine, but then the pusher sends the previous token rather than the new one if i use my second account)

@roiskhoiron
Copy link

I have the same problem

Here's my Pusher config :

static PusherClient? pusher;
static Channel? channel;

static Future<void> initPusher(String token, int userId) async {
 PusherOptions options = new PusherOptions(
      cluster: 'eu',
      auth: new PusherAuth(
        'https://url',
        headers: {
          'authentication': '$token',
        },
      ),
    );

    try {
      pusher = new PusherClient("APP_KEY", options,
          enableLogging: true, autoConnect: false);

        pusher?.connect();

     channel = pusher?.subscribe("private-user" + '$userId');

}catch(e) {
}

After hours of debugging i managed that the pusher client is sending the previous token to the server. (This error only happens when i connect with another account, if it was my first login everything is fine, but then the pusher sends the previous token rather than the new one if i use my second account)

I have the same problem

@yenyichau
Copy link

Do we have any solution on this problem?

@roiskhoiron
Copy link

Do we have any solution on this problem?

i suggest socket_io_client_2

@yenyichau
Copy link

Do we have any solution on this problem?

i suggest socket_io_client_2

Is it socket_io_client? I can't find socket_io_client_2

@roiskhoiron
Copy link

Do we have any solution on this problem?

i suggest socket_io_client_2

Is it socket_io_client? I can't find socket_io_client_2

socket_io_client: ^2.0.0-beta.4-nullsafety.0

@yenyichau
Copy link

Do we have any solution on this problem?

i suggest socket_io_client_2

Is it socket_io_client? I can't find socket_io_client_2

socket_io_client: ^2.0.0-beta.4-nullsafety.0

ok thanks

@MajedDH
Copy link

MajedDH commented Dec 7, 2022

I'm having exactly the same problem.
we're making a new instance of pusher client and giving it new options with new authentication token but still the client is sending the previous token (although the rest of the data is up to date, only the token is being persisted some how.) I think that's a problem of cached headers...

Anyone solved the issue?

@Djihanegh
Copy link

I'm having exactly the same problem. we're making a new instance of pusher client and giving it new options with new authentication token but still the client is sending the previous token (although the rest of the data is up to date, only the token is being persisted some how.) I think that's a problem of cached headers...

Anyone solved the issue?

This may solve your problem , the commit 32ec432.
The pull request is opened here

@vw5921321
Copy link

vw5921321 commented Apr 29, 2024

pusherclient has an instance stored in native code, even if you make a new instance of pusherclient, the native code still does null check on the native pusherclient instance.

to fix this, first change lib/src/pusher/pusher_client.dart to not reuse the same instance.
i've commented out the part that needs to be replaced.

  //   String appKey,
  //   PusherOptions options, {
  //   bool enableLogging = true,
  //   bool autoConnect = true,
  // });

  /// Creates a [PusherClient] -- returns the instance if it's already be called.
  // factory PusherClient(
  //   String appKey,
  //   PusherOptions options, {
  //   bool enableLogging = true,
  //   bool autoConnect = true,
  // }) {
  //   // _singleton ??= PusherClient._(
  //   //   appKey,
  //   //   options,
  //   //   enableLogging: enableLogging,
  //   //   autoConnect: autoConnect,
  //   // );
  //
  //   final initArgs = InitArgs(enableLogging: enableLogging);
  //
  //   _singleton!._init(appKey, options, initArgs);
  //
  //   if (autoConnect) _singleton!.connect();
  //
  //   return _singleton!;
  // }

  PusherClient(
      String appKey,
      PusherOptions options, {
        bool enableLogging = true,
        bool autoConnect = true,
      }) {
    // Create a new instance directly inside the constructor
    final initArgs = InitArgs(enableLogging: enableLogging);
    _init(appKey, options, initArgs);

    if (autoConnect) connect();
  }

then modify the native init func to not null check the native pusherclient instance.

for android,
remove this from android/src.main/kotlin.com.github.chinloyal.pusher/pusher/PusherService.kt
if(_pusherInstance == null) {

for ios,
remove this from ios/Classes/PusherService.swift
if(_pusherInstance == nil) {

@AhmedAlbashaDev
Copy link

if anyone still has this problem
try to use this library

https://pub.dev/packages/dart_pusher_channels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants