Jump to content


Help with connecting to P4 Server

Perforce linux server connection

  • Please log in to reply
8 replies to this topic

#1 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 April 2017 - 06:34 AM

Hi all, just after some assistance with connecting to my Perforce server.   Please bear with me as I am new to Perforce; I've put down all the relevant info I can think of but please say if more information is required.
I have a Linux server running on a cloud host, I am able to ping this from my Windows workstation.  I am SSH'd into it.  I have installed Perforce on this and it is running.  When I installed Perforce, I set P4PORT to ubuntu-Perforce:1666, where 'ubuntu-Perforce' is the machine name.

Running 'p4 info' now returns this:

User name: richardp
Client name: ubuntu-Perforce
Client host: ubuntu-Perforce
Client unknown.
Current directory: /home/richardp
Peer address: 127.0.0.1:40240
Client address: 127.0.0.1
Server address: ubuntu-Perforce.localdomain:1666
Server root: /opt/perforce/servers/perforceserver
Server date: 2017/04/10 06:25:42 +0000 UTC
Server uptime: 00:07:24
Server version: P4D/LINUX26X86_64/2016.2/1498579 (2017/03/21)
ServerID: perforceserver
Server services: standard
Server license: none
Case Handling: sensitive
richardp@ubuntu-Perforce:~$



I then installed P4V on my windows workstation and attempted to connect to Server: xxx.xxx.xxx.xxx:1666 , where that is my server public IP, but it is rejected with this message:
Connect to server failed; check $P4PORT.
TCP connect to xxx.xxx.xxx.xxx:1666 failed.
connect: xxx.xxx.xxx.xxx:1666: WSAECONNREFUSED


I then tried setting my server P4PORT to 'xxx.xxx.xxx.xxx:1666' and also just to '1666', but no improvement.  In this case, then running 'p4 info' on the server returned:
Connect to server failed; check $P4PORT.
TCP connect to 1666 failed.
  connect: 127.0.0.1:1666: Connection refused
\

Additionally, p4 info on server also doesn't work when P4PORT is 'localhost:1666' or '127.0.0.1:1666' , it only works with the hostname.

Note that each time I changed P4PORT I did it with p4 set P4PORT=.... then rebooted the server; I couldn't just stop and start the service because all p4 commands stop working when P4PORT is not that original value.  Do I need to set something in another place of config; not just in the P4PORT environment variable?

One last bit of info; I've tried using Telnet from windows to check if the port 1666 is open but cannot see it.  So I vaguely wonder if I have configured P4 server for internal connections only....

Looking forward to your help chaps :)

Thank you
Richard

#2 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 April 2017 - 09:43 PM

Some further information:

I've found this thread
https://forums.perfo...erver-from-p4v/
and am having the same problem:


Quote

That's interesting. Why does it fail?


blahblah33:/home/perforce => p4 -p localhost:16666 info
Perforce client error:
Connect to server failed; check $P4PORT.
TCP connect to localhost:16666 failed.
connect: 127.0.0.1:16666: Connection refused

when this works?

blahblah33:/home/perforce => p4 -p blahblah33:16666 info
User name: perforce
Client name: perforce
Client host: blahblah33
Client root: /opt/perforce/WORKSPACE/perforce
Current directory: /home/perforce
Peer address: 147.22.111.80:50249
Client address: 147.22.111.80
Server address: blahblah33:16666
Server root: /opt/perforce/P4ROOT
Server date: 2014/10/07 15:36:25 -0600 MDT
Server uptime: 20:50:55
Server version: P4D/LINUX26X86_64/2013.2/740201 (2013/11/11)
Server license: MYEMPLOYER 36 users (support ends 2014/10/16)
Server license-ip: 147.22.111.80:16666
Case Handling: sensitive

It's the same machine, right? Is it a different network interface?   

It has been suggested in that thread that there is a bad startup script, however I don't see any resolution to that.  I installed Perforce only with no changes so I'm assuming it runs the default startup script, does changing P4PORT and restarting the server not also change script startup parameters?

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1038 posts

Posted 10 April 2017 - 10:35 PM

If you set P4PORT on your server to just "1666", then it will accept both external and internal connections (as long as the client can actually reach it, that is).  Setting it to a particular IP:port means it will only accept connections on that IP (e.g. if you set it to 127.0.0.1:1666 it'll only accept localhost connections).

So, before anything else, make sure your server's listening on plain old "1666".

Quote

  connect: 127.0.0.1:1666: Connection refused\

Additionally, p4 info on server also doesn't work when P4PORT is 'localhost:1666' or '127.0.0.1:1666' , it only works with the hostname.

This doesn't make any sense to me, if your hostname resolves to 127.0.0.1 as the connection error suggests.  

Note that each time I changed P4PORT I did it with p4 set P4PORT=.... then rebooted the server; I couldn't just stop and start the service because all p4 commands stop working when P4PORT is not that original value.  Do I need to set something in another place of config; not just in the P4PORT environment variable?


This also doesn't make sense to me since (I think) if you specify just a plain port number the client connects to localhost on that port (which SHOULD work, but apparently isn't?).

I'm a little suspicious of this cloud VM.

#4 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 April 2017 - 11:34 PM

Thanks for your feedback.

From server I can successfully ping localhost 127.0.0.1 or ubuntu-Perforce, so I don't think I've broken the networking itself....

netstat -l:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address    Foreign Address State
tcp     0   0 *:1642   *:* LISTEN
tcp     0   0 ubuntu-Perforce.lo:1666 *:* LISTEN
tcp6    0   0 [::]:1642    [::]:*   LISTEN

#5 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 11 April 2017 - 01:24 AM

Ok sorted.

I rolled my droplet to a snapshot from before I started P4 installation.  From there I reinstalled P4 with only one difference; on the initial configuration script I entered '1666' for the port instead of 'ubuntu-Peforce:1666'.  Now my windows client can connect.
I'm going to put it down to me breaking something... however from what I read, changing the P4PORT environment variable should sort it.  So I dunno.
Anyway thanks for your time :)
Now to have a play with depot setup, including adding an already existing project

#6 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1038 posts

Posted 11 April 2017 - 03:14 AM

View PostStudly_Spud, on 11 April 2017 - 01:24 AM, said:

I rolled my droplet to a snapshot from before I started P4 installation.  From there I reinstalled P4 with only one difference; on the initial configuration script I entered '1666' for the port instead of 'ubuntu-Peforce:1666'.  Now my windows client can connect.
I'm going to put it down to me breaking something... however from what I read, changing the P4PORT environment variable should sort it.  So I dunno.

I was a little curious about that, but since you said there was a difference in behavior based on how you set P4PORT on the server I assumed that was actually working as intended and skipped that debugging step -- should have known better.  :)  Not sure what this config script you're talking about does but the typical thing is to run p4d with the port on the command line (i.e. "p4d -p 1666") to make really sure it's not subject to unexpected environment changes (since command line flags override everything else).

#7 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 11 April 2017 - 03:39 AM

Basically I followed through this guide:
https://www.perforce...er.install.html

post-installation configuration prompted me to run this script:
sudo /opt/perforce/sbin/configure-helix-p4d.sh

I read some other docs, got confused on the first pass, and used the hostname with the port.
Note that even on the second pass I have not run "p4d -p 1666" as it never mentioned it in the guide.... but the server is now auto starting itself and running fine

#8 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 183 posts

Posted 14 April 2017 - 04:57 PM

Unless I missed something, you were not changing the port on the server, only for the client. You wanted:

p4 configure set P4PORT=1666

to modify the server's listening address:port .

#9 Studly_Spud

Studly_Spud

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 17 April 2017 - 08:11 PM

Ah, that'll be it.  I can't go back and test now because I restored and then got it working, but I was missing the 'configure' from that command.  Hopefully this will help someone else who stumbles on this thread.  Thanks!





Also tagged with one or more of these keywords: Perforce, linux, server, connection

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users