I am running on Windows 8.1. I have installed Python 2.7.2, Zope interface 4.1.1 and Twisted 64bits.
When I use twisted, I get a really awkard error.
I have always used twisted and never got this error.
I get this after writing from twisted.internet import reactor, protocol
socket.error: [Errno 10060] A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond
The error is saying the server you are trying to connect to did not respond. You are either not correcting to the right server, or the server is not set up to reply as you are wanting it to. Another possibility is that you do not have the appropriate ports open to make the connection.
Related
The following code works flawlessly in Linux, retrieving the list of folders/files available in the FTP server:
from ftplib import FTP
server = FTP('ftp.ibge.gov.br')
server.connect()
server.login()
server.nlst()
However, in Windows 10, I get the server welcome message after connect() and the '230 login successful" message, but when I try to send any command to the server - like server.nlst() or server.dir() - socket.py raises a TimeoutError [WinError 10060]
I am 100% sure that the server is up, and in Linux server.nlst() retrieves the information fast as lightning - so, it is not a "true" timeout error, if I set timeout=1000, or larger, I get the same error.
What is wrong?
An explanation of the problem can be found here: passive reply with unroutable address
It seems that 'ftp.ibge.gov.br' is not properly configured.
Luckily, I found a working solution.
However, it seems that ftplib is not able to handle this problem in Windows only. With Linux, I have been accessing files from this server for years using ftplib
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...
A week back I posted this, and about 2 weeks back I posted this, both pertaining to an ever evolving issue with my Python sockets. I've also asked a question on the Wireshark Stack Exchange, and even after all 3 posts, I haven't been able to reach any conclusion. So heres the problem:
When I start up IDLE, it returns an error: IDLE Subprocess: socket error: No connection could be made because the target machine actively refused it and then I press ok on the dialogue boxes and it closes it out. But the issue isn't only limited to IDLE.
Any TCP ports I try to connect to via the Python socket module will fail. For example, if I run a server and a client (server first, of course, and both have the current IP of my computer and the port 45002) locally on my computer it returns: [Errno 10061] No connection could be made because the target machine actively refused it. So someone on an earlier post told me that running both the programs locally on a Windows machine will not work because it doesn't have a loopback interface (although when I look at my network interfaces via CMD, Loopback interface is listed for some reason). So then I went ahead and put the server on the computer with the issue, and the client on another computer on the network. It returns: [Errno 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. But for some reason, if I run the server on the other computer and then run the client on the computer with the issue, the server and client actually connect, and then the server fails claiming: [Errno 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied, even though I made sure to include a .connect(addr) in the client program. Sorry if this is getting confusing, but it's going to get a bit more complicated than this.
After this mess of running servers/clients on different computers, per request of another answerer on an early post, I installed Wireshark and began looking for packets being sent on the ports I am using. The results were a little weird. When I run the server on the computer with the issue, and the client on the other computer, Wireshark catches absolutely no packets on the port of the server, and the client fails with the errno 10060, as I said earlier. If I run the server from the other computer and the client from the computer with the issue, Wireshark catches some ordinary SYNs and ACKs. I only get an RST when I end the Python.exe process (this info is really only important to people who are good with Wireshark/networking, it's really only extra info).
I've also tried capturing packets from the IDLE program with Wireshark after I pinpointed the range of ports that it tends to use. When I start it up, no packets on any port in the range. Again, this is really just extra info to any of you who may be able to make something of it.
Again, sorry for the confusion, but I must go on.
And now, the issue that brought all this up. The problem that really caused me to ask myself "Hmm... Why is Python not working correctly?", my Twisted server was not able to import the reactor module returning the errno 10061. If you don't use/know of Twisted, all that's really needed to understand the problem is that, to import the reactor module, Twisted has to setup a Python TCP port, which is not working.
This issue has left me (and presumably everyone who's read it) scratching their head. I am sure that the ports I am using are not used. I'm sure the IP addresses are correct and matching. I am sure that there is no firewall blocking the connections, since I have tried running the programs without a firewall on with no luck. I am running a Wireless Windows 64bit laptop.
Heres my client program, and here's my server program, if they help at all.
Any suggestions, ideas, or answers are welcomed. At this point, any at all. Thanks.
P.S. If there is any info I can provide, or anything I can do to help find the solution to this issue, please tell. Also, I know this question is barely a programming one, so if there is somewhere else I am supposed to put this, please say and I'll move it over.
EDIT: Seems like I solved one piece of the puzzle. I can now connect a client on the computer with the issue to the computer with no issue, but not the other way around (running the client on the good computer, and running server on the broken one). I had to switch servSock.recv(buff) to cliSock.recv(buff) on the server side.
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.
We are using Carrot in our Python project. I wrote a Python script acting as the consumer of the message queue. I invoked this Python script using command line shell in Windows 7 as
python consumer.py
However, after a while, the running session was aborted and the error is:
[errno 10054] An existing connection was forcibly closed by the remote host
The producer session is still running fine on the Linux server. Just wondering how can I fix this and have a long running consumer session on Windows .
I don't know Carrot/AMQP, but I'd first of all check if the AMQP server logged an error at the time your client got disconnected. It could be that you just have to expect these errors to occur from time to time and upon disconnection, catch the exception(?) and reestablish the connection.