【问题标题】:I am getting Auth Error: Authentication failure due to [java.io.FileNotFoundException: while implementing pusher-js in Android studio我收到 Auth Error: Authentication failure due to [java.io.FileNotFoundException: while implementation pusher-js in Android studio
【发布时间】:2020-10-08 04:42:03
【问题描述】:

我正在尝试使用 Laravl 作为服务器端和 Android 作为客户端来实现 pusher-js 我的代码如下所示

   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");

我成功建立了与套接字的连接,但得到 [com.pusher.client.AuthorizationFailureException: java.io.FileNotFoundException: 我的授权链接是:https://bleepcare.com/laravel-websockets/auth

【问题讨论】:

  • 我有同样的问题,但没有得到解决方案,我也问过这个问题,但它被删除了。
  • 好的,你知道的也请更新我
  • 您能分享错误消息的完整堆栈跟踪吗?如果不使用 setHost 会怎样?
  • 我只面临授权问题,但我发现授权链接无效,您能告诉我未经授权订阅私人频道的方式

标签: java android sockets pusher


【解决方案1】:

我已经通过允许 hashmap.put("accept) 成功订阅私有频道的所有类型和套接字解决了这个问题

【讨论】:

  • 嗨@Jawad Goraya 你能帮我解决同样的问题吗
  • hashmap.put("accept) 这是什么意思?这甚至不是有效的代码
猜你喜欢
  • 2022-12-01
  • 2021-07-10
  • 2021-08-07
  • 2016-03-29
  • 2022-07-20
  • 2021-01-09
  • 2022-12-28
  • 1970-01-01
  • 2020-12-23
相关资源
最近更新 更多