I am new to python socket programming and was following a tutorial building a chat-app, using kivy and sockets. I am running my server on my main PC and I was trying to connect from my laptop to this Server, but it doesn't work (Both my PC and laptop are connected via Ethernet cable). When I run the client.py on the PC that I host my Server on, everything works fine.
I tried running the Server on my 0.0.0.0 address and then connecting from my laptop to the IP address that appears on my Server PC if I type in "ipconfig" (192.168.2.x) but it didn't work. I also tried running the server just on the Ethernet-Adapter IP that appears when I type in "ipconfig" (so 192.168.2.x) but this doesn't work neither.
Lastly I have tried defining my Server IP by using the built in socket function: socket.gethostbyname(socket.gethostname()) (weirdly when I run this, my Server runs on my VMware Network Adapter (192.168.66.x) instead of my Ethernet-Adapter). But this too didn't work :(
The client.py code on my laptop always returns this error:
connection error: [WinError 10060] 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
Would appreciate any help :)
edit: Could this have something to do with the firewall on my PC blocking connections or something?
Found the Problem! Today it actually worked by disabling my host PCs Windows Defender internal Firewall and the running the Server on 0.0.0.0, which is very weird because yesterday it didn't work...
Related
Hello I tried a simple server and client script on my pc. It was working perfectly but when I tried to connect with pc server with my mobile it is not working I can't connect to pc server with my mobile client
Nothing works I tried changing ip not working I tried changing my laptop internet connection not working I tried using a third party app it says couldn't connect to host and my server script is completely fine
both devices will need to be on the same WLAN or Wifi Network.
you will also need to get your PC's network IP Address (eth0 or your main network card), then you will need your server to listen on ip 0.0.0.0 with the port you want to use.
Have a close look at your firewall and enabled outbound/inbound connnections for the port that you are using.
then you will need to put step 2's ip address as the server ip
then this should work
I wonder and i've been trying everything to get my program with python sockets to work remotely. When I say remotely is like, I run the server in my computer and my friend at his house can run the client and connect to my server. Is this possible without using Hamachi? Pls let me know, because I'm already dying by trying so many things and installing and uninstalling programs.
You have to activate port forwarding on your router so that everything that comes on the specific port is forwarded to your local IP (and the port should be open).
Situation
I wrote a simple program in python. It's a simple socket chatting program. In my program, the client just connect to an address (ip, port) and send a message, while at this time the server is ready and receives the message and prints it. I can assure the program is correct, since I tried on my computer.
I have a VM instance on Google Cloud Platform, which I can operate through ssh, a simple way provided by google cloud. I can make sure the server is working.
Problem
I start a simple tcp server, python program on my google cloud server. Then I start my client program on my computer. But I get this error:
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
or equivalently in Chinese:
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
How do I solve this problem and connect to my google cloud server?
I guess maybe the firewall refused my computer's connection, but have no idea how to solve it.
This error means that your program is not listening on 0.0.0.0 port XYZ.
Check to see if your program is instead listening on localhost. If it is change to 0.0.0.0 which means all available networks. localhost means do not listen on any network interfaces and only accept connections from inside the computer.
Then double check the port number.
To see if you have something listening run this command (Linux): netstat -at
Look for a line with your port XYZ.
When you start your program, make sure that it does not error when creating the listener. If you are trying to use a port number below 1024, you will need to lauch the program with root privileges.
The TCP connection is being refused because the GCP Firewall is indeed blocking it. Therefore, you must create a firewall rule that opens the TCP port for Ingress connections.
By navigating to Firewall rules in the VPC network section of the GCP Console, you can create firewall rules or update existing ones.
One approach is to tag your GCE instance, and when creating the firewall rule, set the target to be this tag, and as for 'Source filters', the IP of the machine you're attempting to establish the connection from, or simply allow all IPs to connect with 0.0.0.0/0 as the source. Remember to specify the TCP port that needs to be opened.
I have developed a Django application which I wish to deploy on apache2.4 server. I have configured mod_wsgi and stuff on a system, which is going to be my server and localhost:8081 (apache's port) is working properly on the server system. I am in a corporate environment. When I wish to access the application from another system, I am unable to access the page.(The server and client are in the same network, both using LAN)
Observations:
8081 port is listening on my server system
(Proto: TCP, Local Address: 0.0.0.0:8081, Foreign Address: Computername:0, State: LISTENING)
I am unable to telnet to server ip on port 8081
(Connecting To 10.176.241.35...Could not open connection to the host, on port 8081: Connect failed)
Able to ping server IP (EDIT)
I have JDeveloper installed in my server system and I am able to access
the homepage of WebLogic server from another system though.
Site can't be reached, took too long to respond error while trying to
access the page from client system
What all I have done so far:
Followed the exact steps mentioned in here for configuring apache with django
Turned off firewall in both client and server systems
Add inbound and outbound exception rules in Advcanced firewall
settings in both client and server systems
I am unable to know the root cause of this problem and I have been working on this for a week and a half. I do not have much knowledge in networking and I am badly in need of some help. Sorry if the question is too naive.
It seems the socket connection through paramiko (v1.10.0) is not stable.
I have two computers. The python code is on the PC one. The connection sometime is successful and sometime is not (Same code). When the PC paramiko code fails (socket.error, 10060), I use my Mac via terminal ssh login the server and everything is fine.
I use set_missing_host_key_policy in the code. But the Mac has the key I guess. I typed yes when login at the first time.
If the unstable connection is caused by the hotkey, how do I get the host key? From the server or somewhere in my local folder (win7)?
Try switching off Windows firewall. It's a network error, it should not be because of SSH key problems.
Error Code 10060: Connection timeout
Background: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties.