Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servname not supported for ai_socktype

I'm running a Centos virtual machine using Vagrant. The machine seems to run properly, but when I try to sync Perforce I can see the following error:

[vagrant@vagrant-c5-x86_64 ~]$ /perforce/p4 sync -f ...  
Perforce client error:  
Connect to server failed; check $P4PORT.  
failed.TCP connect to perforce.xxx.com:1666  
Servname not supported for ai_socktype

I have read this http://www.ducea.com/2006/09/11/error-servname-not-supported-for-ai_socktype/ and tried to set the ports in /etc/services, but it didn't work. I am not even sure if the problem is Perforce or OS related.

Any hints?

like image 817
Tavo Avatar asked Apr 15 '14 09:04

Tavo


2 Answers

I had this problem with a Tornado/Python app. Apparently, this can be caused by the port being interpreted as a string instead of an integer. So in my case, I needed to change my startup script to force it to be interpreted as an integer.

application = tornado.web.Application(...)
application.listen(int(port))
like image 106
z0r Avatar answered Sep 18 '22 07:09

z0r


Are you able to enter your client ? before trying to sync the files, try to create a perforce client:

p4 client

Maybe it's not the host:port that is the issue, but other flags in the connection string that interrupt.

I personally received the exact same error, but it was a Perforce issue.

The reason is, Perforce has its own priority when it's looking for its P4USER/P4PORT/... configuration.

  1. ENV variables ( run export )
  2. if a P4CONFIG variable was specified somewhere it can search in a file ( like .perforce in the current/upper directory )

Problem was, even though it first search for an ENV variable - the P4CONFIG file might override it.

So my $P4PORT ENV variable had a connection string X, but the .perforce file had a connection string Y.

Removing the P4PORT from my local .perforce file - solved this issue. in example:

$~] echo $P4PORT; 
rsh:ssh -2 -q -a -x -l p4ssh perforce.mydomain.com

$~] cat .perforce
# P4PORT="rsh:ssh -q -a -x -l perforce.mydomain.com /bin/true"
P4USER="my_user"

Also remember that Perforce will search for the $P4CONFIG file ( if configured one ) in the entire directory hierarchy upwards, so even if you don't have the file in the current directory - it might be found in an upper directory, and there - you might have a $P4PORT configuration that you didn't expect..

like image 36
Ricky Levi Avatar answered Sep 18 '22 07:09

Ricky Levi