helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.45k stars 563 forks source link

TCP/TLS support in helidon #6958

Open Rajatsr opened 1 year ago

Rajatsr commented 1 year ago

Hi Team, We need Helidon(SE or MP) to expose raw TCP sockets(like springboot). Currently this support is not present in either Helidon SE or Helidon MP. The main ask here is that the microservice build out of helidon framework shall be able to receive TCP/TLS packets. These packets will have proprietary data as a payload. This way the framework will support building services that will handle application protocol data over TCP/TLS.

Environment Details


Problem Description

currently frameworks like SpringBoot, Vertx provides support to create microservices which will listen on TCP sockets. What this means is that these microservices can accept the messages(proprietary protocol) which comes on top of TCP/TLS packets. (as a payload)

Once the tcp packets land at microservice, it should be able to handle it, process it and do the next action.

The example of same in Spring boot is - https://github.com/dipeti/feedme-tcp-kafka/tree/master/src/main/java/dinya/peter/feedme https://github.com/zhwxp/spring-boot-tcp-server-sample

The example of same in vertx is - https://github.com/vert-x3/vertx-examples/tree/master/core-examples#echo https://www.javatips.net/api/reactmann-master/reactmann-core/src/main/java/reactmann/TcpMessageVerticle.java https://vertx.io/docs/vertx-core/java/#_writing_tcp_servers_and_clients

Steps to reproduce

Not reproducible - New enhancement

tomas-langer commented 9 months ago

In Helidon 4 (currently release candidate) you can implement your own io.helidon.webserver.spi.ServerConnectionSelector (a ServiceLoader service) to identify connection based on its initial bytes. So if you want to create a custom protocol, you can create such an implementation and associate it with your own routing that can be registered as usual with the webserver (both HTTP/1 and HTTP/2 are implemetned this way in Helidon itself, custom routing is used for example for grpc and WebSocket). We also have extensible support for HTTP/1.1 upgrades if that is what you want (used for WebSocket and HTTP/2), or for "sub-protocols" of HTTP/2 (used for grpc) Also supported is ALPN (protocol negotiation over TLS), where you can provide your own protocol ID to be negotiated.