alibaba / alibaba/anyproxy

java代码部署在docker上面使用httpclient请求anyproxy起的mock服务 报错 404

Open
#497 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Plese fill the template when you reporting a new issue, thanks!

1、Java代码httpclient请求方法部署在docker服务器上
2、请求我物理机上部署的anyproxy mock服务报错 404 (网络是通的没有问题)
3、在docker 上使用 curl -X POST 命令请求我物理机上的anyproxy 的mock 是可以正常返回正确结果的
4、postman 等其他工具请求都是可以返回正确结果的
5、Java代码httpclient请求方法部署在阿里云服务器上 本地服务器上 请求anyproxy mock服务都是可以正确返回结果的
6、anyproxy里面的规则文件内容如下:
module.exports = {
summary:'测试mock样例!',
*beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === '/test') {
const newResponse = responseDetail.response;
newResponse.statusCode=200;
newResponse.header={ 'Content-Type': 'application/json' };
newResponse.body = '测试mock样例';
return new Promise((resolve, reject) => {
setTimeout(() => { // delay
resolve({ response: newResponse });
}, 0);
});
}
},
};
7、测试步骤:
![image](https://user-images.githubusercontent.com/50006193/56783303-c9c54600-681d-11e9-95ea-7301e06a2445.png)
![image](https://user-images.githubusercontent.com/50006193/56783342-fa0ce480-681d-11e9-9ccf-eff2ebedf9d9.png)
![image](https://user-images.githubusercontent.com/50006193/56783477-83bcb200-681e-11e9-8c16-e8ddd57daa38.png)
![image](https://user-images.githubusercontent.com/50006193/56783645-5a505600-681f-11e9-86b8-048ccd7e1e67.png)
以上步骤是用命令求的结果都可以:
但是在代码里请求就会出现以下问题
![image](https://user-images.githubusercontent.com/50006193/56784209-ff6c2e00-6821-11e9-9e0b-2ea0f49c9426.png)
监听端口并没有抓到任何请求
anyproxy 日志里也没有对应的请求信息

#### Which platform are you running AnyProxy

docker
#### The version of the AnyProxy

anyproxy --version :4.0.12
#### Your expected behavior of AnyProxy

测试mock样例
#### The actual behavior of AnyProxy

![image](https://user-images.githubusercontent.com/50006193/56784209-ff6c2e00-6821-11e9-9e0b-2ea0f49c9426.png)

#### The log of the error

anyproxy没有任何日志

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Java HttpClient request method, the Docker deployment details, and the AnyProxy 4.0.12 rule shown in the issue; compare its behavior with the working curl POST request. Check why the request produces no AnyProxy log entry. Done means identifying the request-path difference and documenting a reproducible fix or configuration change.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, node.js
Domain
devops, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.