Currently i have work on Python socket server on Openshift. Managed to get it listen to port (15000) and tested on local with telnet seems working fine.
However, i unable to connect to the socket server other than local ( either telnet to the socket server or using Adobe Air xmlsocket )
when i do a netstat on the server, i got following result:
netstat -tan | grep $OPENSHIFT_PYTHON_IP | grep $OPENSHIFT_PYTHON_PORT | grep ESTABLISHED
/proc/net/tcp: Permission denied
not sure whether i missed anything on the configuration on Openshift.
Btw, how can i get the IP of my server? if i use OPENSHIFT_PYTHON_IP the ip is only for local right?
Your websocket server needs to listen on port 8080, and you need to access it at ws://app-domain.rhcloud.com:8000
Related
I create a simple python server:
import socket
server=socket.socket()
server.bind(("0.0.0.0",8820))
server.listen(1)
(client_socket,client_address)=server.accept()
client_name=client_socket.recv(1024)
client_socket.send("Hello "+client_name)
client_socket.close()
server.close()
when I run this script in a VPS I cannot connect to this server
why?
(I get the IP address of the server( with ifconfig command on bash console) and when I run a client script that connect to this address it doesn't connect)
Try to bind the socket server to the vps public IP address and try to avoid ports bellow 10,000 I think most of firewalls prevent incoming connections through ports under 10,000.
I was wondering if I have index.html and in windows CMD run python -m http.server 80 while in the directory with index.html will it start a server on my IP(given I have port 80 open) and then people can just connect to my IP and see what is in index.html?
If
your router is portforwarded for TCP 80
the server is listening on 0.0.0.0
No firewalls are in the way
Then it will be publically accessible. To make it only available on local host you should host on 127.0.0.1
httpd = ServerClass(("127.0.0.1", 80), HandlerClass)
Edit: the other answer posted this good link, didn't see until after posting: Is it possible to run python SimpleHTTPServer on localhost only?
People should be able to connect to your public IP without problem. It would be a little more complex if you want to give access only from localhost:
Is it possible to run python SimpleHTTPServer on localhost only?
I was setting up a public Ipython Notebook in my remote Ubuntu 12.04 server according to http://ipython.org/ipython-doc/1/interactive/public_server.html#notebook-public-server, but when all was done, I cannot connect to it via both chrome and safari (in both https and http modes), I got timeout error in chrome, safari told me server isn't responding. So I tested the system by setting up following simple python server:
python -m SimpleHTTPServer
And the same error occured. I also checked the port with sudo netstat -anltp|grep :8000, which seems fine:
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 22683/python
What surprises me is that I have the apache running and holding websites just fine (I also try to turn it off when configuring python server but that didn't help). Can anyone give me a clue what might be wrong in the Ubuntu server and how I should debug it?
I have found the issue: it turns out that the ports are closed by firewall, although in netstat it says python is listening to port 8000, but when incoming request reaches port 8000 it is rejected before getting to python server. By opening the ports the issue can be well resolved.
It turns out that the ports are closed by firewall, although in netstat it says python is listening to port 8000, but when incoming request reaches port 8000 it is rejected before getting to python server. By opening the ports the issue can be well resolved.
I'm having an issue running and connecting to my python django server on a windows 2012 server. To run the server I use command: python manage.py 0.0.0.0:80. This results in an error below
[Error 10013]: an attempt was made to access a socket in a way forbidden by its access permissions
I've tried running the command prompt as an administrator with no change. For reference, I am able to run the server on port 8000 but then I cannot connect to the port remotely. I have turned off firewalls as well so that is probably not the issue.
While it is preferable to run the django on port 80, I am trying to get this working on any port.
Port 80 (and many other ports) is reserved by Windows Server. Checkout this https://serverfault.com/questions/633179/cant-make-confluence-run-on-port-80-with-windows-server-2012-r2,
You may want to google "Windows Server Reserved port" for more info and a way to "unreserve" it.
telnet
server ←————→ device
↑
| SSH
↓
localhost (me)
I have a device that is connected with one server computer and I want to talk to the device by ssh'ing into the server computer and send telnet commands to my device. How do I setup things in Python to make this happen?
You can use Python's paramiko package to launch a program on the server via ssh. That program would then in turn receive commands (perhaps via stdin) and return results (via stdout) from the controlling program. So basically you'll use paramiko.SSHClient to connect to the server and run a second Python program which itself uses e.g. telnetlib to talk to the device.
Use tunneling by setting up a SSH session that tunnels the Telnet traffic:
So ssh from localhost to server with the option -L xxx:deviceip:23
(xxx is a free port on localhost, device is the IP address of "device", 23 is the telnet port).
Then open a telnet session on your localhost to localhost:xxx. SSH will tunnel it to the device and response is sent back to you.