mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
Disable HTTP proxy for gRPC connections (#6744)
* disable http proxy for grpc * add test
This commit is contained in:
@@ -7,6 +7,7 @@ import collections
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import sys
|
||||
@@ -24,6 +25,19 @@ import ray.test_utils
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# https://github.com/ray-project/ray/issues/6662
|
||||
def test_ignore_http_proxy(shutdown_only):
|
||||
ray.init(num_cpus=1)
|
||||
os.environ["http_proxy"] = "http://example.com"
|
||||
os.environ["https_proxy"] = "http://example.com"
|
||||
|
||||
@ray.remote
|
||||
def f():
|
||||
return 1
|
||||
|
||||
assert ray.get(f.remote()) == 1
|
||||
|
||||
|
||||
def test_simple_serialization(ray_start_regular):
|
||||
primitive_objects = [
|
||||
# Various primitive types.
|
||||
|
||||
@@ -38,8 +38,13 @@ class GrpcClient {
|
||||
public:
|
||||
GrpcClient(const std::string &address, const int port, ClientCallManager &call_manager)
|
||||
: client_call_manager_(call_manager) {
|
||||
std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(
|
||||
address + ":" + std::to_string(port), grpc::InsecureChannelCredentials());
|
||||
grpc::ChannelArguments argument;
|
||||
// Disable http proxy since it disrupts local connections. TODO(ekl) we should make
|
||||
// this configurable, or selectively set it for known local connections only.
|
||||
argument.SetInt(GRPC_ARG_ENABLE_HTTP_PROXY, 0);
|
||||
std::shared_ptr<grpc::Channel> channel =
|
||||
grpc::CreateCustomChannel(address + ":" + std::to_string(port),
|
||||
grpc::InsecureChannelCredentials(), argument);
|
||||
stub_ = GrpcService::NewStub(channel);
|
||||
}
|
||||
|
||||
@@ -50,6 +55,7 @@ class GrpcClient {
|
||||
quota.SetMaxThreads(num_threads);
|
||||
grpc::ChannelArguments argument;
|
||||
argument.SetResourceQuota(quota);
|
||||
argument.SetInt(GRPC_ARG_ENABLE_HTTP_PROXY, 0);
|
||||
std::shared_ptr<grpc::Channel> channel =
|
||||
grpc::CreateCustomChannel(address + ":" + std::to_string(port),
|
||||
grpc::InsecureChannelCredentials(), argument);
|
||||
@@ -85,4 +91,4 @@ class GrpcClient {
|
||||
} // namespace rpc
|
||||
} // namespace ray
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user