2017-08-18 15 views
0

cometdバージョン3.1.2とjetty 9.4.6.v20170531を使用して、cometdのドキュメントのコードを使用して、非常にシンプルなcometd javaサーバーとクライアントのセットアップを試みました。最も簡単な作業cometd java client

HttpClient httpClient = new HttpClient(); 
httpClient.start(); 

Map<String, Object> options = new HashMap<String, Object>(); 
ClientTransport transport = new LongPollingTransport(options, httpClient); 
BayeuxClient client = new BayeuxClient("http://localhost:9025/mycontext/cometd/", transport); 

client.handshake(); 
boolean handshaken = client.waitFor(5000, BayeuxClient.State.CONNECTED); 
if (handshaken) { 
    System.out.println("Yes"); 
    // Here handshake is successful 
} 
System.out.println("Done"); 

サーバーのセットアップは、私は本当に興味が何か、そして春はcometdサーブレットが埋め込ま桟橋サーバを注入しています。私が何を試しても、クライアントはハンドシェイクしません。私は、POST http://localhost:9025/mycontext/cometd

は200 ...

[ 
    { 
     "minimumVersion": "1.0", 
     "clientId": "11jlmrekgqnu9v1i4w1b8rgiq3c", 
     "supportedConnectionTypes": [ 
      "long-polling", 
      "websocket" 
     ], 
     "advice": { 
      "interval": 0, 
      "timeout": 60000, 
      "reconnect": "retry" 
     }, 
     "channel": "/meta/handshake", 
     "id": "1", 
     "version": "1.0", 
     "successful": true 
    } 
] 
を返す...
[{ 
    "version": "1.0", 
    "minimumVersion": "0.9", 
    "channel": "/meta/handshake", 
    "supportedConnectionTypes": [ 
     "long-polling", 
     "callback-polling" 
    ], 
    "advice": { 
     "timeout": 60000, 
     "interval": 0 
    }, 
    "id": "1" 
}] 

...最後に、サーバーが正常に郵便配達でこのリクエストを送信することにより、セットアップおよび使用可能であることを証明することができました

...だから、明らかに、サーバーの設定は問題ありません。私はブレークポイントを設定し、トラフィックを探すためにtcpflowを使用しました。私の言うことは、起動テストのドキュメントからcometdの独自のライブラリを使用している最も単純なクライアントは、決してリクエストを送信しません。 tcpトラフィックはありません。誰でも私が逃していることを知っていますか?どんな助けもありがたい。

+0

"私が何を試しても、クライアントはハンドシェイクをしません。"それが投げている特定のエラーはありますか? – Brian

答えて

0

何か他のことが起こっている必要があります。

あなたのコードは正しいです、そして、CometDテストスイートは何百ものテストのためにそのコードを正確に使用しています。

CometD documentationtroubleshooting sectionにお読みください。

org.cometdカテゴリのDEBUGロギングレベルを有効にして、取得したログを確認してください。問題が何であるかは明らかです。

まだ問題がある場合は、CometD Issue Trackerの問題にログを添付してください。

関連する問題