diff --git a/src/dubbo/protocol/triple/protocol.py b/src/dubbo/protocol/triple/protocol.py index 1326507..f4aa4d3 100644 --- a/src/dubbo/protocol/triple/protocol.py +++ b/src/dubbo/protocol/triple/protocol.py @@ -31,8 +31,7 @@ from dubbo.remoting.aio import constants as aio_constants from dubbo.remoting.aio.http2.protocol import Http2ClientProtocol, Http2ServerProtocol from dubbo.remoting.aio.http2.stream_handler import ( - StreamClientMultiplexHandler, - StreamServerMultiplexHandler, + StreamClientMultiplexHandler ) from dubbo.url import URL @@ -74,10 +73,8 @@ def export(self, url: URL): listener_factory = functools.partial(ServerTransportListener, self._path_resolver, method_executor) - # Create a stream handler - stream_multiplexer = StreamServerMultiplexHandler(listener_factory) # set stream handler and protocol - url.attributes[aio_constants.STREAM_HANDLER_KEY] = stream_multiplexer + url.attributes[aio_constants.LISTENER_FACTORY_KEY] = listener_factory url.attributes[common_constants.PROTOCOL_KEY] = Http2ServerProtocol # Create a server diff --git a/src/dubbo/remoting/aio/constants.py b/src/dubbo/remoting/aio/constants.py index 17712a8..103c184 100644 --- a/src/dubbo/remoting/aio/constants.py +++ b/src/dubbo/remoting/aio/constants.py @@ -18,6 +18,8 @@ STREAM_HANDLER_KEY = "stream-handler" +LISTENER_FACTORY_KEY = "listener-factory" + CLOSE_FUTURE_KEY = "close-future" HEARTBEAT_KEY = "heartbeat" diff --git a/src/dubbo/remoting/aio/http2/protocol.py b/src/dubbo/remoting/aio/http2/protocol.py index a11f671..a762d0a 100644 --- a/src/dubbo/remoting/aio/http2/protocol.py +++ b/src/dubbo/remoting/aio/http2/protocol.py @@ -22,9 +22,11 @@ from h2.config import H2Configuration from h2.connection import H2Connection +from dubbo.constants import common_constants from dubbo.loggers import loggerFactory from dubbo.remoting.aio import ConnectionStateListener, EmptyConnectionStateListener, constants as h2_constants from dubbo.remoting.aio.exceptions import ProtocolError +from dubbo.remoting.aio.http2.stream_handler import StreamServerMultiplexHandler from dubbo.remoting.aio.http2.controllers import RemoteFlowController from dubbo.remoting.aio.http2.frames import ( DataFrame, @@ -76,7 +78,11 @@ def __init__(self, url: URL, h2_config: H2Configuration): self._flow_controller: Optional[RemoteFlowController] = None - self._stream_handler = self._url.attributes[h2_constants.STREAM_HANDLER_KEY] + if self._url.attributes[common_constants.PROTOCOL_KEY] == Http2ServerProtocol: + listener_factory = self._url.attributes[h2_constants.LISTENER_FACTORY_KEY] + self._stream_handler = StreamServerMultiplexHandler(listener_factory) + else: + self._stream_handler = self._url.attributes[h2_constants.STREAM_HANDLER_KEY] # last time of receiving data self._last_read = time.time()