1

我正在尝试开发一个简单的 Java PubSubHubBub 应用程序。我下载了这个示例代码来测试它,但是当我尝试订阅时,我总是收到错误 409。按照 PuSH 规范,我在这个链接上创建了自己的提要: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,一切正常。

你能给我一些关于我做错了什么的信息吗?我的提要中有任何错误吗?

4

0 回答 0