我正在尝试开发一个简单的Java PubSubHubBub应用程序。我下载了this sample code来测试它,但是当我尝试订阅时,我总是收到错误409。 根据PuSH规范,我在此链接创建了自己的Feed:receivetemplate.eu01.aws.af.cm/feed /
这是订阅者的Test类中的代码:
package sub;
import java.net.InetAddress;
import PubSubHubbub.Web;
import PubSubHubbub.Subscriber;
public class Test {
private static Web webserver;
private static Subscriber sbcbr;
private static String hostname = null;
private static Integer webserverPort = 8080;
private static void startServer(){
try {
webserver = new Web(webserverPort);
sbcbr = new Subscriber(webserver);
InetAddress addr = InetAddress.getByName("receivetemplate.eu01.aws.af.cm");
hostname = addr.getHostName();
System.out.println("http://" + hostname + "/");
hostname = "http://" + hostname + "/";
} catch (Exception e) {
e.printStackTrace();
System.out.println("WebServer can not start");
}
}
public static void main(String[] args) {
try {
String hub = "http://pubsubhubbub.appspot.com/subscribe";
String hub_topic = "http://receivetemplate.eu01.aws.af.cm/feed/";
startServer();
int statusCode = sbcbr.subscribe(hub, hub_topic, hostname, null, null);
if (statusCode == 204){
System.out.println("the status code of the subscription is 204: the request was verified and that the subscription is active");
} else if (statusCode == 202){
System.out.println("the status code of the subscription is 202: the subscription has yet to be verified (i.e., the hub is using asynchronous verification)");
} else{
System.out.println("the status code of the subscription is:" + statusCode);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
如果我用http://pubsubhubbub-subscriber.appspot.com/替换hub_topic,如果我将pubsubhubbub-subscriber.appspot.com传递给InetAddress.getByName(),我得到的响应是204,一切正常。
你能告诉我一些关于我做错事的信息吗?我的Feed中有错误吗?