ptrd / kwik

A QUIC client, client library and server implementation in Java. Supports HTTP3 with "Flupke" add-on.
GNU General Public License v3.0
390 stars 57 forks source link

how to trandport rtmp use kwik? #19

Closed wangpeng1 closed 2 years ago

wangpeng1 commented 2 years ago

can you give some sample with only transport date use kwik,but not use http

ptrd commented 2 years ago

Hi,

Sure. It boils down to:

String alpn = "other application protocol";
quicConnection.connect(connectionTimeout, alpn, null, null);
QuicStream stream = quicConnection.createStream(bidirectional);
OutputStream output = stream.getOutputStream();
output.write(....);
InputStream input = stream.getInputStream();
input.read(....);
ptrd commented 2 years ago

And even though you don't want to use http, the https://bitbucket.org/pjtr/kwik/src/master/src/main/java/net/luminis/quic/run/SampleClient.java does give a pretty good and simple example of how to use a Kwik connection. So that makes me wonder what you are struggling with, to me it seems a pretty simple API to use.... What would you recommend me to do to improve?

wangpeng1 commented 2 years ago

@ptrd At present, I am investigating the solution, how to transmit rtmp data to the server through quic on Android mobile phones. Since I don't know much about quic, I don't know how to combine rtmp and quic, and what additional work needs to be done. The problem I solved is that the mobile phone signal is not good, TCP will retransmit and cause more delay, so I want to use quic to improve it. I want to use the kwik solution, and to complete when the mobile phone signal is not good, the rtmp push stream can be elegantly pushed to the server to have a better experience, I will continue to do some work,shall you draw a kwic structure diagram or overall architecture diagram,I think it helps us understand the whole project, I hope we can communicate more and get your Help, thanks a lot.

wangpeng1 commented 2 years ago

@ptrd I don't quite understand applicationProtocol in the sample is "hq-32", is it Quic version ? if it isnot ,if i can use rtmp,if i can write “rtmp”?

ptrd commented 2 years ago

"Since I don't know much about quic, I don't know how to combine rtmp and quic, and what additional work needs to be done." - "shall you draw a kwic structure diagram or overall architecture diagram"

I can help you understand how Kwik implementation works (and i will because it will help others too), but you should first take some effort to understand the QUIC protocol yourself. There are enough resources on the web about QUIC and HTTP3.

"how to combine rtmp and quic," QUIC is a transport protocol, just like TCP. So, it's not really "combining", rtmp will run on top of QUIC, just like it runs on top of TCP.

"hq-32" is the application protocol running over QUIC that is used in interop testing of QUIC implementations. It is HTTP 0.9 over QUIC version draft-32. If you would now write a HTTP3 client with Kwik, you should use "h3", which is the official identifier for HTTP3 (see https://www.rfc-editor.org/rfc/rfc9114.html#name-registration-of-http-3-iden).

What ALPN id you need to use for rtmp should be defined in the rtmp specification. If there is no specification for rtmp over QUIC (yet), than the identifier will be defined by the people writing the experimental implementations.....

Hth Cheers Peter