gpt4 book ai didi

java - 我收到 Auth Error : Authentication failure due to [java. io.FileNotFoundException: while implementation pusher-js in Android studio

转载 作者:行者123 更新时间:2023-12-03 11:50:24 26 4
gpt4 key购买 nike

我正在尝试使用 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

最佳答案

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

关于java - 我收到 Auth Error : Authentication failure due to [java. io.FileNotFoundException: while implementation pusher-js in Android studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62444650/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com