pusher_client icon indicating copy to clipboard operation
pusher_client copied to clipboard

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

Open godwintrav opened this issue 3 years ago • 11 comments

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?

godwintrav avatar Jun 30 '21 19:06 godwintrav

Can you share your pusher configuration?

chinloyal avatar Aug 13 '21 09:08 chinloyal

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)

Djihanegh avatar Sep 28 '21 15:09 Djihanegh

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

roiskhoiron avatar Oct 04 '21 04:10 roiskhoiron

Do we have any solution on this problem?

yenyichau avatar Oct 29 '21 03:10 yenyichau

Do we have any solution on this problem?

i suggest socket_io_client_2

roiskhoiron avatar Oct 29 '21 03:10 roiskhoiron

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

yenyichau avatar Oct 29 '21 04:10 yenyichau

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

roiskhoiron avatar Oct 29 '21 04:10 roiskhoiron

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

yenyichau avatar Oct 29 '21 04:10 yenyichau

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?

MajedDH avatar Dec 07 '22 11:12 MajedDH

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

Djihanegh avatar Dec 08 '22 15:12 Djihanegh

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) {

vw5921321 avatar Apr 29 '24 05:04 vw5921321