0
  String url = "some_url";
  HttpClient httpClient = new HttpClient();
  httpClient.start();
  Map<String, Object> options = new HashMap<String, Object>();
  LongPollingTransport transport = new LongPollingTransport(options, httpClient);
  BayeuxClient client = new BayeuxClient(url, transport);
  client.getChannel(Channel.META_HANDSHAKE).addListener(new ClientSessionChannel.MessageListener() {
     public void onMessage(ClientSessionChannel channel, Message message) {
         System.out.println(message);
     }
  });
  client.handshake();

取得

{"failure":{"exception":"org.cometd.common.TransportException: {httpCode=403}","message":{"supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"2","version":"1.0"},"httpCode":403,"connectionType":"long-polling"},"channel":"/meta/handshake","id":"2","subscription":null,"successful":false}

したがって、私の最初の推測は、承認ヘッダーを追加することです。どうやってやるの?Jetty 9 は、サーバーとクライアントの両方のコード ライブラリに使用されます。

4

1 に答える 1

1

それを行う方法を示すこのテストケースを見てください。

于 2016-04-13T17:40:18.257 に答える