Replies: 3 comments 4 replies
-
I can tell you that the Neo4j database server uses approach 1 to support http, https, and their custom bolt protocol, all on one port. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Sorry for arrive later, I can confirm that ActiveMQ Artemis uses the same approach (1) too |
Beta Was this translation helpful? Give feedback.
3 replies
-
I would definitely recommend 1). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I want to multiplex two protocols (lets call them P1, P2) on the same ports. That means, if a client sends request in P1, the server will handle the request and also sends P1 responses. It will continue to talk to the same client/session/context with the same protocol untill it is closed. Another client, sends request with P2, and again, the server respondes with P2 also.
The server can talk to multiple clients at the same time, each session can be diffirent protocol.
I have 2 approaches, and I need your advice on this matter:
Approach 1
When server initializes channel, it sets the pipeline to use a single handler, lets call it
ProtocolHandler
.This handler decodes the request and decides which protocol to use.
After it decides the protocol, it replaces the handler
ProtocolHandler
withP1Handler
for P1 protocol, or replaces withP2Handler
for P2 protocol.It will also add encoders/decoders and more handlers, but this is the basic idea.
Approach 2
(This is what my current project is doing, altough it uses diffirent network stack: Apache Mina, instead of Netty, but it has the same concepts for pipeline like netty)
When server initializes channel, it sets the pipeline to have all of the handlers. So right away we add all the handlers we will use.
Slowly, the request goes one handler at a time. If the handler is not the correct protocol, we remove the current pipeline (in the same handler) like so:
pipeline.remove(this)
.Personally, I feel this is the wrong approach. Although it works, I can't argue with that.
By your experience, what do you think is the best approach to solve this problem (of multiplexing two protocols or more on the same port) ?
Regards, Shlomi.
Beta Was this translation helpful? Give feedback.
All reactions