docker - PACT.Net 无法分配请求的地址

标签 docker pact

我目前正在尝试在 docker 容器中运行 pact.net 示例测试,但出现以下错误:

Starting test execution, please wait...
pact-consumer-tests    | [xUnit.net 00:00:19.9436627]     
pact_consumer.tests.AddConsumerTest.Add_customer [FAIL]
pact-consumer-tests    | Failed   
pact_consumer.tests.AddConsumerTest.Add_customer
pact-consumer-tests    | Error Message:
pact-consumer-tests    |  System.AggregateException : One or more errors 
occurred. (One or more errors occurred. (Cannot assign requested 
address)) (The following constructor parameters did not have matching 
fixture data: ConsumerApiPact data)
pact-consumer-tests    | ---- System.AggregateException : One or more 
errors occurred. (Cannot assign requested address)
pact-consumer-tests    | -------- System.Net.Http.HttpRequestException : 
Cannot assign requested address
pact-consumer-tests    | ------------ System.Net.Sockets.SocketException 
: Cannot assign requested address
pact-consumer-tests    | ---- The following constructor parameters did 
not have matching fixture data: ConsumerApiPact data
pact-consumer-tests    | Stack Trace:
pact-consumer-tests    |
pact-consumer-tests    | ----- Inner Stack Trace #1 
(System.AggregateException) -----
pact-consumer-tests    |    at 
PactNet.Mocks.MockHttpService.Host.RubyHttpHost.Start() in 
C:\projects\pact- 
net\PactNet\Mocks\MockHttpService\Host\RubyHttpHost.cs:line 65
pact-consumer-tests    |    at PactNet.PactBuilder.MockService(Int32 
port, JsonSerializerSettings jsonSerializerSettings, Boolean enableSsl, 
IPAddress host) in C:\projects\pact-net\PactNet\PactBuilder.cs:line 82
pact-consumer-tests    |    at 
pact_consumer.tests.context.ConsumerApiPact..ctor() in /app/pact- 
consumer.tests/context/ConsumerApiPact.cs:line 27
pact-consumer-tests    | ----- Inner Stack Trace -----
pact-consumer-tests    |    at 
System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, 
CancellationToken cancellationToken)
....

无论我向 Host IPAddress.Any AND IpAddress.Loopback 的框架发送什么内容,但我似乎仍然遇到这个问题?

我错过了什么吗?它在 Docker 容器中运行,没有其他服务运行..

我可以使用 dotnet test 在 OSX 上运行它,一切都很好。

提前非常感谢

理查德

最佳答案

System.Net.Sockets.SocketException:无法分配请求的地址 看起来系统确实无法绑定(bind)到端口 - 您确定该端口在主机上可用(而不仅仅是 Docker)容器)?

关于docker - PACT.Net 无法分配请求的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51099626/

相关文章:

docker-compose - 我可以在不重新启动容器的情况下更新标签吗?

docker - 将现有 heroku 应用程序的堆栈从 heroku-18 设置为 Docker 镜像的 'container'?

php - Docker CodeIgniter 路由重定向到 Docker IP

postgresql - 使用 Docker : sqlalchemy. exc.OperationalError : (psycopg2. OperationalError) FATAL: 用户 "username"的密码验证失败

docker - Alpine 上哪个库包含 cdefs.h?

c++ - C++ API 的消费者驱动合约测试

javascript - 为多个响应集测试相同的 API

gradle - Pact Gradle 状态 url 响应

node.js - 我可以使 Chai 的 Expect.to.not.throw 同步吗?