Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unset http proxy #5972

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jina/serve/runtimes/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def _get_server(self):
grpc_server_options=self.args.grpc_server_options,
ssl_keyfile=getattr(self.args, 'ssl_keyfile', None),
ssl_certfile=getattr(self.args, 'ssl_certfile', None),
proxy=getattr(self.args, 'proxy', None),
)

elif len(self.args.protocol) == 1 and self.args.protocol[0] == ProtocolType.HTTP:
Expand Down
8 changes: 8 additions & 0 deletions jina/serve/runtimes/servers/grpc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

import os
import grpc
from grpc import RpcError
from grpc_health.v1 import health, health_pb2, health_pb2_grpc
Expand All @@ -20,21 +21,28 @@ def __init__(
grpc_server_options: Optional[dict] = None,
ssl_keyfile: Optional[str] = None,
ssl_certfile: Optional[str] = None,
proxy: bool = False,
**kwargs,
):
"""Initialize the gateway
:param grpc_server_options: Dictionary of kwargs arguments that will be passed to the grpc server as options when starting the server, example : {'grpc.max_send_message_length': -1}
:param ssl_keyfile: the path to the key file
:param ssl_certfile: the path to the certificate file
:param proxy: If set, respect the http_proxy and https_proxy environment variables, otherwise, it will unset these proxy variables before start. gRPC seems to prefer no proxy
:param kwargs: keyword args
"""
super().__init__(**kwargs)
if not proxy and os.name != 'nt':
os.unsetenv('http_proxy')
os.unsetenv('https_proxy')

self.grpc_server_options = grpc_server_options
self.grpc_tracing_server_interceptors = self.aio_tracing_server_interceptors()
self.ssl_keyfile = ssl_keyfile
self.ssl_certfile = ssl_certfile
self.health_servicer = health.aio.HealthServicer()


async def setup_server(self):
"""
setup GRPC server
Expand Down
Loading