这里是我的代码订阅私人渠道,当我试图使私人订阅,然后我得到一个错误信息
推动器错误消息: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>
在Java中我的JAX-RS Web服务
@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推杆:无法从你的webapp身份验证信息:500
此外,在我的Eclipse控制台显示它不同类型的错误:
java.lang.NoClassDefFoundError:组织/阿帕奇/ HTTP /康涅狄格州/ HttpClientConnectionManager所致
抛出java.lang.ClassNotFoundException:org.apache.http.conn.HttpClientConnectionManager从[模块“deployment.medecube.war:主”从服务模块加载器]
我发现我的问题解决方案。其实我忘了添加HttpClient的行家依赖于推在我pom.xml
file.So这就是为什么推杆未能加载resource.By添加maven的依赖我得到了我的回应。
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>