0

I'm new to openshift,django and python and having a hard time trying to have two internal ports available for a python app I'm trying to install on openshift.

I read some previous post about doing this and I used the code below in an action_hook/deploy with no success.

I also attempted to execute the commands in a python shell via SSH. I received no errors, but when I did a netstat (using value returned from os.environ['OPENSHIFT_PYTHON_IP']), I still do not see the port listed.

Host = os.environ['OPENSHIFT_PYTHON_IP']
bPort = 28081
jqPort = 28092

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((Host, jqPort))

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((Host, bPort))

LIke I said I'm new to both openshift, python and django, and don't know what else to do.

David
  • 1

1 Answers1

0

I figured out the issue was in the application.

The application was attempting to bind to the port using local ip address (127.0.0.1), and it needed to use the Openshift assigned IP address. I may have been looking at something wrong when I was using netstat, because even though the above script is using the correct IP address it did not look like it was actually working. When I used the below script (I found on stackoverflow,Check If port is open) to debug, I saw that in fact it was working.

import socket;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1',80))
if result == 0:
   print "Port is open"
else:
   print "Port is not open"
Community
  • 1
  • 1
David
  • 1