Skip to content

Commit

Permalink
fix client ip
Browse files Browse the repository at this point in the history
  • Loading branch information
HexToString committed Aug 17, 2021
1 parent d870d33 commit b6d3a79
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion java/README_CN.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ java -cp paddle-serving-sdk-java-examples-0.0.1-jar-with-dependencies.jar Pipeli

### 注意事项

1.在示例中,端口号都是9393,ip默认设置为了0.0.0.0表示本机,注意ip和port需要与Server端对应。
1.在示例中,端口号都是9393,ip默认设置为了127.0.0.1表示本机,注意ip和port需要与Server端对应。

2.目前Serving已推出Pipeline模式(原理详见[Pipeline Serving](../doc/PIPELINE_SERVING_CN.md)),面向Java的Pipeline Serving Client已发布。

Expand Down
16 changes: 8 additions & 8 deletions java/examples/src/main/java/PaddleServingClientExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ boolean http_proto(String model_config_path) {
List<String> fetch = Arrays.asList("price");

Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
String result = client.predict(feed_data, fetch, true, 0);
Expand All @@ -49,7 +49,7 @@ boolean http_json(String model_config_path) {

Client client = new Client();
//注意:跨docker,需要设置--net-host或直接访问另一个docker的ip
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.set_http_proto(false);
client.loadClientConfig(model_config_path);
Expand All @@ -73,7 +73,7 @@ boolean grpc(String model_config_path) {
List<String> fetch = Arrays.asList("price");

Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
client.set_use_grpc_client(true);
Expand All @@ -97,7 +97,7 @@ boolean encrypt(String model_config_path,String keyFilePath) {
List<String> fetch = Arrays.asList("price");

Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
client.use_key(keyFilePath);
Expand Down Expand Up @@ -125,7 +125,7 @@ boolean compress(String model_config_path) {
List<String> fetch = Arrays.asList("price");

Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
client.set_request_compress(true);
Expand Down Expand Up @@ -176,7 +176,7 @@ boolean yolov4(String model_config_path,String filename) {
}};
List<String> fetch = Arrays.asList("save_infer_model/scale_0.tmp_0");
Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
String result = client.predict(feed_data, fetch, true, 0);
Expand All @@ -198,7 +198,7 @@ boolean bert(String model_config_path) {
}};
List<String> fetch = Arrays.asList("pooled_output");
Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
String result = client.predict(feed_data, fetch, true, 0);
Expand Down Expand Up @@ -268,7 +268,7 @@ boolean cube_local(String model_config_path) {
}};
List<String> fetch = Arrays.asList("prob");
Client client = new Client();
client.setIP("0.0.0.0");
client.setIP("127.0.0.1");
client.setPort("9393");
client.loadClientConfig(model_config_path);
String result = client.predict(feed_data, fetch, true, 0);
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/io/paddle/serving/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public Client() {
feedTensorLen_ = null;
feedNameToIndex_ = null;
timeoutS_ = 200000;
ip = "0.0.0.0";
ip = "127.0.0.1";
port = "9393";
serverPort = "9393";
serviceName = "/GeneralModelService/inference";
Expand Down
2 changes: 1 addition & 1 deletion python/paddle_serving_client/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def data_bytes_number(datalist):
# 或者直接调用grpc_client_predict()
class HttpClient(object):
def __init__(self,
ip="0.0.0.0",
ip="127.0.0.1",
port="9393",
service_name="/GeneralModelService/inference"):
self.feed_names_ = []
Expand Down
2 changes: 1 addition & 1 deletion python/paddle_serving_server/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
def port_is_available(port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2)
result = sock.connect_ex(('0.0.0.0', port))
result = sock.connect_ex(('127.0.0.1', port))
if result != 0:
return True
else:
Expand Down
2 changes: 1 addition & 1 deletion python/paddle_serving_server/server.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def prepare_server(self,
def port_is_available(self, port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2)
result = sock.connect_ex(('0.0.0.0', port))
result = sock.connect_ex(('127.0.0.1', port))
if result != 0:
return True
else:
Expand Down
2 changes: 1 addition & 1 deletion python/paddle_serving_server/web_service.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
def port_is_available(port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2)
result = sock.connect_ex(('0.0.0.0', port))
result = sock.connect_ex(('127.0.0.1', port))
if result != 0:
return True
else:
Expand Down
2 changes: 1 addition & 1 deletion python/pipeline/util.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, start_port=12000):
def port_is_available(port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2)
result = sock.connect_ex(('0.0.0.0', port))
result = sock.connect_ex(('127.0.0.1', port))
if result != 0:
return True
else:
Expand Down

0 comments on commit b6d3a79

Please sign in to comment.