Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCPServer Error: Cannot assign requested address - bind(2) for "::1" port #79

Open
waelemara opened this issue Nov 7, 2017 · 4 comments

Comments

@waelemara
Copy link

waelemara commented Nov 7, 2017

Hi,

I have followed the instructions mentioned here https://github.com/pact-foundation/pact-ruby-standalone/releases for the Linux x64 platform.

When I run the this command ./pact-mock-service start
I get the following message

INFO WEBrick 1.3.1
INFO ruby 2.2.2 (2015-04-13) [x86_64-linux]
WARN TCPServer Error: Cannot assign requested address - bind(2) for "::1" port 9222
INFO WEBrick::HTTPServer#start: pid=671 port=9222

I see this warning "TCPServer Error" only on the Linux Platform, I have tried Windows and OSX and both are working fine.
In the message it says it is a warning but in reality the server is not up or not accessible.

Steps to reproduce

docker run -it -p 9222:9222 microsoft/aspnetcore-build /bin/bash
curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.18.0/pact-1.18.0-linux-x86_64.tar.gz
tar xzf pact-1.18.0-linux-x86_64.tar.gz
cd pact/bin
./pact-mock-service start

Can you please shed some light on this issue.

Thanks

@dursk
Copy link

dursk commented Nov 7, 2017

What's your /etc/hosts look like? I was able to resolve by commenting out

::1	localhost ip6-localhost ip6-loopback

but it's less than desirable...

@bethesque
Copy link
Member

Try setting an explicit --host=0.0.0.0 and --port=1234

@waelemara
Copy link
Author

@dursk I have tried your option, it works, but the mock service is not accessible from outside the container.
@bethesque I have tried your option and it is working as expected, and the mock service is accessible from outside the container.

netstat results after applying both options
Option 1
tcp 0 localhost:1234 0.0.0.0:* LISTEN
Option 2
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN

ATM the second option is not viable for me as I'm using a wrapper library is there is a way to achieve the same netstat results but without passing --host flag?

I'm already working with the consumer library to have that option open in the API.

Thanks very much and appreciate your time.

@bethesque
Copy link
Member

Neil should be able to get the fix out pretty quickly. The only other option is to do a small hack to the ruby file. Somewhere inside the .net code will be the ruby-standalone package. You'll have to do some exploring because I don't know where that is. Open up pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-{LATEST_VERSION}/lib/pact/mock_service/cli.rb

Find the line with desc 'start' (about line 52) then find the line method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost' Change the 'localhost' to '0.0.0.0'.

I believe the .net impl might actually be using the service command, so change the default in that one too (about line 20).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants