2017-04-21 25 views
1

我正在使用Netty來設置一個簡單的http/2服務器。我使用this作爲http/2服務器的例子。爲什麼netty http2服務器總是使用奇數的streamId

要測試此服務器,我使用netty示例client。在那裏,我將請求發送到服務器

我的客戶端代碼:
完整代碼:http://netty.io/5.0/xref/io/netty/example/http2/client/package-summary.html

HttpResponseHandler responseHandler = initializer.responseHandler(); 
    int streamId = 3; 
    HttpScheme scheme = SSL ? HttpScheme.HTTPS : HttpScheme.HTTP; 
    AsciiString hostName = new AsciiString(HOST + ':' + PORT); 
    System.out.println("Sending request(s)..."); 
    if (URL != null) { 
     System.out.println("with url"); 

     // Create a simple GET request. 
     FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, URL); 
     request.headers().add(HttpHeaderNames.HOST, hostName); 
     request.headers().add(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), scheme.name()); 
     request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP); 
     request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.DEFLATE); 
     responseHandler.put(streamId, channel.writeAndFlush(request), channel.newPromise()); 
     streamId += 2; 


    } 

上面的代碼工作正常流ID 3,5等。
但是,當我更改流ID爲任何其他數字如4,6,8等,上述代碼不起作用。從服務器我仍然得到流的id 3,5,7等消息我無法找到這些流id的內部邏輯example server

回答