From cff5ea7424432e2339d53ad60f65c06e8ba1d672 Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Wed, 16 Mar 2022 11:20:12 +0100 Subject: [PATCH 1/2] fix: ws scheme --- docarray/array/mixins/post.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docarray/array/mixins/post.py b/docarray/array/mixins/post.py index 3a8932822c0..f3cbf65f2e6 100644 --- a/docarray/array/mixins/post.py +++ b/docarray/array/mixins/post.py @@ -45,6 +45,8 @@ def post( ) batch_size = batch_size or len(self) + _tls = r.scheme in ('grpcs', 'https', 'wss') + if r.scheme.startswith('jinahub'): from jina import Flow @@ -63,7 +65,10 @@ def post( from jina import Client - c = Client(host=r.hostname, port=_port, protocol=r.scheme) + if r.scheme.startswith('ws'): + r.scheme = 'websocket' # temp patch for the core + + c = Client(host=r.hostname, port=_port, protocol=r.scheme, https=_tls) return c.post( _on, inputs=self, From 338b03b9e66c3a872d9d3a20f12e79f183de6dab Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Wed, 16 Mar 2022 11:58:15 +0100 Subject: [PATCH 2/2] fix: ws scheme --- docarray/array/mixins/post.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docarray/array/mixins/post.py b/docarray/array/mixins/post.py index f3cbf65f2e6..c36e3b72c37 100644 --- a/docarray/array/mixins/post.py +++ b/docarray/array/mixins/post.py @@ -45,9 +45,17 @@ def post( ) batch_size = batch_size or len(self) - _tls = r.scheme in ('grpcs', 'https', 'wss') + _scheme = r.scheme + _tls = False - if r.scheme.startswith('jinahub'): + if _scheme in ('grpcs', 'https', 'wss'): + _scheme = _scheme[:-2] + _tls = True + + if _scheme == 'ws': + _scheme = 'websocket' # temp fix for the core + + if _scheme.startswith('jinahub'): from jina import Flow f = Flow(quiet=True, prefetch=1).add(uses=standardized_host) @@ -59,16 +67,13 @@ def post( request_size=batch_size, parameters=parameters, ) - elif r.scheme in ('grpc', 'http', 'ws'): + elif _scheme in ('grpc', 'http', 'ws', 'websocket'): if _port is None: raise ValueError(f'can not determine port from {host}') from jina import Client - if r.scheme.startswith('ws'): - r.scheme = 'websocket' # temp patch for the core - - c = Client(host=r.hostname, port=_port, protocol=r.scheme, https=_tls) + c = Client(host=r.hostname, port=_port, protocol=_scheme, https=_tls) return c.post( _on, inputs=self,