Pusher Error: Couldn't get auth info from your webapp : 500 (Focus at 500 error)
Pusher Error: Couldn't get auth info from your webapp : 500 (Focus at 500 error)
这是我订阅私人频道的代码,当我尝试进行私人订阅时,我收到一条错误消息
推送器错误消息:Couldn't get auth info from your webapp : 500
场景:
订阅在 javaHTML 文件中的脚本中:
<!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>
我的 JAX-RS 网络服务 在 java
@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
(Internal Server Error)
pusher.min.js:8 Pusher : Couldn't get auth info from your webapp : 500
同样在我的 eclipse 控制台 它显示不同类型的错误:
Caused by: java.lang.NoClassDefFoundError:
org/apache/http/conn/HttpClientConnectionManager
java.lang.ClassNotFoundException:
org.apache.http.conn.HttpClientConnectionManager from [Module
"deployment.medecube.war:main" from Service Module Loader]
我找到了我的问题的解决方案。
实际上我忘记在我的 pom.xml
file.So 中为 pusher 添加 HttpClient maven 依赖项,这就是为什么 pusher 加载失败 resource.By 添加 maven 依赖项我得到了我的回应。
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
这是我订阅私人频道的代码,当我尝试进行私人订阅时,我收到一条错误消息
推送器错误消息:Couldn't get auth info from your webapp : 500
场景:
订阅在 javaHTML 文件中的脚本中:
<!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>
我的 JAX-RS 网络服务 在 java
@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 (Internal Server Error)
pusher.min.js:8 Pusher : Couldn't get auth info from your webapp : 500
同样在我的 eclipse 控制台 它显示不同类型的错误:
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager from [Module "deployment.medecube.war:main" from Service Module Loader]
我找到了我的问题的解决方案。
实际上我忘记在我的 pom.xml
file.So 中为 pusher 添加 HttpClient maven 依赖项,这就是为什么 pusher 加载失败 resource.By 添加 maven 依赖项我得到了我的回应。
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>