Reputation: 1
In my Netty-incubator-codec-http3 application, the server creates a new stream to the client, calls writeAndFlush()
, but the client doesn't receive the data.
Client and server successfully connect and create an initial bidirectional stream. Server-initiated streams, created over the established QuicChannel, are not delivering data to the client, despite the connection remaining active.
//server
...
try {
Bootstrap bs = new Bootstrap();
Channel channel = ....sync();
//i want to send data to client test
ScheduledExecutorService timerExecutor = new ScheduledThreadPoolExecutor(1);
timerExecutor.scheduleAtFixedRate(
() -> {
try {
hand();
} catch (InterruptedException e) {
e.printStackTrace();
}
},
5, 5, TimeUnit.SECONDS);
} finally {
group.shutdownGracefully();
}
}
private static void hand() {
//QUIC_CHANNEL_LIST :client connect to server success,server save it
for (QuicChannel quicChannel : QuicServerExample.QUIC_CHANNEL_LIST) {
//it is my protobuf
TdataProtoBuf.Tdata request = TdataProtoBuf.Tdata.newBuilder()
.setQueryKeyBlob("server-asd123123f")
.build();
NettyMessage nettyMessage = new NettyMessage("lty.TdataProtoBuf$Tdata", request, 0);
try {
// explicitly create a new stream and send data
QuicStreamChannel streamChannel = quicChannel.createStream(QuicStreamType.BIDIRECTIONAL,
new ChannelInitializer<QuicStreamChannel>() {
@Override
protected void initChannel(QuicStreamChannel ch) {
// my Decoder and Encoder
ch.pipeline()
.addLast(new ProtocolV1Decoder())
.addLast(new ProtocolV1Encoder());
}
}).sync().getNow();
// after executed streamChannel.writeAndFlush .
//no log output include send success or send error...
streamChannel.writeAndFlush(nettyMessage).addListener(future -> {
if (future.isSuccess()) {
System.out.println("send success");
} else {
System.err.println("send error: " + future.cause());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
Upvotes: 0
Views: 25