I am getting Auth Error: Authentication failure due to [java.io.FileNotFoundException: while implementing pusher-js in Android studio

Viewed 474

I am trying to implement pusher-js using Laravl as server side and Android as client side My code is given below

   HashMap<String,String> hashMap = new HashMap<>();
    hashMap.put("Authorization","Bearer "+mToken);
    hashMap.put("Content-Type", "application/x-www-form-urlencoded");
    hashMap.put("Accept", "application/json");
    hashMap.put("Client-id","anyid");

    HttpAuthorizer authorizer = new HttpAuthorizer("https://bleepcare.com/laravel-websockets/auth");
    authorizer.setHeaders(hashMap);
    PusherOptions options = new PusherOptions();
    options.setAuthorizer(authorizer);
    options.setEncrypted(true);
    options.setCluster("mt1");
    options.setWsPort(6001);
    options.setWssPort(6001);
    options.setUseTLS(true);
    options.setHost("bleepcare.com");
    options.buildUrl("anykey");

    Pusher pusher = new Pusher("anykey",options);
    pusher.connect(new ConnectionEventListener() {
        @Override
        public void onConnectionStateChange(ConnectionStateChange change) {
            Log.i(TAG,"Connection State: "+change.getCurrentState());
            if (change.getCurrentState().name().equals("CONNECTED")) {


            }
        }

        @Override
        public void onError(String message, String code, Exception e) {
            Log.i(TAG,"Connection Error: "+e.getMessage());
        }
    });
    channel = pusher.subscribePrivate("private-AppointmentChat.12.3", new PrivateChannelEventListener() {
        @Override
        public void onAuthenticationFailure(String message, Exception e) {
       Log.i(TAG,"Auth Error: "+String.format("Authentication failure due to [%s], exception was [%s]", message, e));
        }

        @Override
        public void onSubscriptionSucceeded(String channelName) {
        Log.i(TAG,"Success : "+channelName);
        }

        @Override
        public void onEvent(PusherEvent event) {
            Log.i(TAG,"Event : "+event);
        }
    },"AppointmentMessage");

i successfully establish connection with sockets but getting [com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: my auth link is : https://bleepcare.com/laravel-websockets/auth

1 Answers

i have solved this issue by allowing hashmap.put("accept) to all types and sockets subscribed to private channel successfully

Related