How to connect Rpi via websockets python - python

I am trying to connect my raspberry pi to my computer via websockets python. The server is running on the computer and the client on the Rpi. The two of them are connected to the same Wifi network.
When I run the client side on the Rpi I can't connect it to the server.
I am running the server on 0.0.0.0:8000 and I get this Error:
Errno111 Connect call failed ('0.0.0.0', 8000)
Do you know if there is a thing I need to do to be able to connect them? For info, the server and the client can connect when they are running on the same computer but different terminals.
Thanks in advance

Related

Connect RaspberryPi to Localhost(127.0.0.1)

I am trying to connect Pi to my local server, but it doesn't work when I type 127.0.0.1 on pi's browser.
I have created a flask web server at 127.0.0.1:5000 on my PC, and several websites are attached. (I have to set up the web server outside the Pi since I run multiple OpenCV applications on the server, and Pi is too slow to run it.) Pi connected to the Ethernet, and I knew its IP address (ex:123.456.789.0). I run a python script with socketio on Pi, and I want the python script to communicate with the flask web server. How can I do that? Be simple, how to control(communicate) raspberry (CAM, GPIO) from an outside network with a web server.
Now the Pi and PC are NOT under the same network. Their IP addresses are totally different, but I can make them under the same network (ex. Pi:192.168.0.1, PC:192.168.0.2) if it is needed.
Thank you!

How to connect Choregraphe/Python script to remote Pepper robot from different network?

A robot is connected to a network with restricted outbound traffic. Only inbound traffic is allowed from one specific IP address(ours IP, e.g. 111.111.111.111). All outgoing traffic is forbidden.
There is settings and dhcp corresponding to external IP(e.g. 222.222.222.222). We want to connect to Pepper from the IP 111.111.111.111. The connection through SSH is fine with ssh nao#222.222.222.222 and password but we can not connect through Choregraphe or Python scripts. This is very important because we want to be able to connect with the robot remotely to upload different Choregraphe applications.
This is the error when we are trying to connect with a Python script:
[W] 18872 qimessaging.transportsocket: connect: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
...
RuntimeError: Failed to connect to service ALBehaviorManager on machine 1296211e-1921-3131-909b-69afa37ааа28. All endpoints are unavailable.
The Choregraphe hangs and crashes after a certain period of time.
Can you give me some advice?
NAOqi connections go through port 9559 by default, so you could check whether that one is blocked.
If you are unable to connect through port 9559, you can do a port forwarding. But I think this is a more network related question.

How to connect to vmware web server from windows?

I have a Windows PC with VMWare installed on it.
I have created a Django web server on VMWare (Ubuntu Server OS, Bridged Network, IP 192.168.1.7) and I can SSH to it from Windows PC.
My web server already run at http://127.0.0.1:8080/.
February 24, 2018 - 16:58:55
Django version 2.0.2, using settings 'fortress_of_mobile_phone.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CONTROL-C.
But when I tried to connect to this web server from Windows PC then I got the following error:
This site can’t be reached
192.168.1.7 refused to connect.
Could you please take some time help me to fix it. Thank you.
That's your problem, it's listening on 127.0.0.1, you have to make it listen to 0.0.0.0 or 192.168.1.7.
Check here How to specify which eth interface Django test server should listen on?

Run python server on VPS

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.

Connecting to Python XML RPC from the Mac

I wrote an XML RPC server in python and a simple Test Client for it in python. The Server runs on a linux box. I tested it by running the python client on the same linux machine and it works.
I then tried to run the python client on a Mac and i get the following error
socket.error: (61, 'Connection Refused')
I can ping and ssh into the linux machine from the Mac. So i dont think its a configuration or firewall error.
Does anyone have any idea what could be going wrong?
The code for the client is as below:
import xmlrpclib
s = xmlrpclib.ServerProxy('http://143.252.249.141:8000')
print s.GetUsers()
print s.system.listMethods()
"Connection Refused" means the connection was REFUSED - the machine 143.252.249.141 is up, and in the network, but is not accepting connections on port 8000 - it is actively refusing them.
So maybe the server software isn't running on the server? Or is running in another port? Or is bound to a different IP address?

Categories

Resources