以下是我订阅私人频道的代码,当我尝试进行私人订阅时,我收到了错误消息
推送错误消息:Couldn't get auth info from your webapp : 500
情境:
订阅位于 HTML 文件:
中的javascript中<!DOCTYPE html>
<head>
<title>Pusher Test</title>
<script src="https://js.pusher.com/3.2/pusher.min.js"></script>
<script>
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('9272f25541ab7b04fc60', {
authEndpoint: 'http://localhost:8080/medecube/rest/initial/pusher/auth',
auth: {
headers: {
'X-CSRF-Token': "12345"
}
}
});
var channel = pusher.subscribe('private-channel');
channel.bind('pusher:subscription_succeeded', function() {
var triggered = channel.trigger('client-myEvent', { "message": "i am pusher client" });
});
</script>
</head>
我在
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@Path("/pusher/auth")
public String processMessagesAndAuthentication( MultivaluedMap<String, String> input){
Pusher pusher = new Pusher("269783", "Pusher-key", "5bbebf61fb77dbef45bc");
String socket_id = input.getFirst("socket_id");
String channel_name = input.getFirst("channel_name");
String auth = pusher.authenticate(socket_id, channel_name);
return auth;
}
错误
POST http://localhost:8080/medecube/rest/initial/pusher/auth 500 (内部服务器错误)
pusher.min.js:8 Pusher:无法从您的webapp获取身份验证信息:500
同样在我的 eclipse控制台中,它显示了不同类型的错误:
引起:java.lang.NoClassDefFoundError: 组织/阿帕奇/ HTTP /康恩/ HttpClientConnectionManager
抛出java.lang.ClassNotFoundException: 来自[Module。的org.apache.http.conn.HttpClientConnectionManager “服务模块加载器”中的“deployment.medecube.war:main”
答案 0 :(得分:1)
我找到了问题的解决方案。
实际上我忘了在我的pom.xml
文件中为推送器添加HttpClient maven依赖项。这就是为什么推送器无法加载资源的原因。通过添加maven依赖关系,我得到了我的响应。
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>