Skip to content

Commit 969bff1

Browse files
authored
Merge pull request #172 from L-jasmine/fix/windows
[backend] remove proxy when request api-server
2 parents 30beab9 + 7dee6de commit 969bff1

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

moxin-backend/src/backend_impls/api_server.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl BackendModel for LLamaEdgeApiServer {
165165

166166
let file_id = file.id.to_string();
167167

168-
let url = format!("http://127.0.0.1:{}/echo", listen_addr.port());
168+
let url = format!("http://localhost:{}/echo", listen_addr.port());
169169

170170
let file_ = file.clone();
171171

@@ -176,7 +176,13 @@ impl BackendModel for LLamaEdgeApiServer {
176176
async_rt.spawn(async move {
177177
let mut test_server = false;
178178
for _i in 0..600 {
179-
let r = reqwest::get(&url).await;
179+
let r = reqwest::ClientBuilder::new()
180+
.no_proxy()
181+
.build()
182+
.unwrap()
183+
.get(&url)
184+
.send()
185+
.await;
180186
if let Ok(resp) = r {
181187
if resp.status().is_success() {
182188
test_server = true;
@@ -219,14 +225,17 @@ impl BackendModel for LLamaEdgeApiServer {
219225
) -> bool {
220226
let is_stream = data.stream.unwrap_or(false);
221227
let url = format!(
222-
"http://127.0.0.1:{}/v1/chat/completions",
228+
"http://localhost:{}/v1/chat/completions",
223229
self.listen_addr.port()
224230
);
225231
let mut cancel = self.running_controller.subscribe();
226232

227233
async_rt.spawn(async move {
228234
let request_body = serde_json::to_string(&data).unwrap();
229-
let resp = reqwest::Client::new()
235+
let resp = reqwest::ClientBuilder::new()
236+
.no_proxy()
237+
.build()
238+
.unwrap()
230239
.post(url)
231240
.body(request_body)
232241
.send()
@@ -284,8 +293,13 @@ impl BackendModel for LLamaEdgeApiServer {
284293
}
285294

286295
fn stop(self, _async_rt: &tokio::runtime::Runtime) {
287-
let url = format!("http://127.0.0.1:{}/admin/exit", self.listen_addr.port());
288-
let _ = reqwest::blocking::get(url);
296+
let url = format!("http://localhost:{}/admin/exit", self.listen_addr.port());
297+
let _ = reqwest::blocking::ClientBuilder::new()
298+
.no_proxy()
299+
.build()
300+
.unwrap()
301+
.get(url)
302+
.send();
289303
let _ = self.model_thread.join();
290304
}
291305
}

0 commit comments

Comments
 (0)