java代码部署在docker上面使用httpclient请求anyproxy起的mock服务 报错 404
- 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、测试步骤:




以上步骤是用命令求的结果都可以:
但是在代码里请求就会出现以下问题

监听端口并没有抓到任何请求
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

#### 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