I'm making a program that needs to recieve a connection hash from a server. When I use:
connhash = s.recv(1024)
I get this error:
[Errno 10054] An existing connection was forcibly closed by the remote host
Is this my fault or the servers fault?
Here is some of the code leading up to s.recv()
stringfmt = u'%(user)s;%(host)s:%(port)d'
string = stringfmt % data
structfmt = '!bh'
encoded = string.encode('utf-16BE')
packetbytes = struct.pack(structfmt, 2, len(encoded))+encoded
s.send(packetbytes)
connhash = s.recv(1024)
I am using Python v 2.7
EDIT: This is for Minecraft just so you know.
-
she server closes the connection - maybe because you're sending something it doesn't understand, maybe because it's not working correctly... it's impossible to say who's fault it is without more information.mata– mata2012年12月08日 22:15:54 +00:00Commented Dec 8, 2012 at 22:15
-
Forcibly to me sounds like an RST (as opposed to FIN)... but if you really want to know, you should probably do a packet capture (tcpdump, wireshark, etc).FatalError– FatalError2012年12月08日 22:23:50 +00:00Commented Dec 8, 2012 at 22:23
1 Answer 1
It sounds like the remote server doesn't like your connection and cuts you off. This could mean you've made a protocol mistake (i.e., the commands you are sending are incorrect), or you may not have logged in successfully, or your IP may have been banned, or many other similar things.
To debug it, you could try using something like telnet to replicate the connection and see where the error occurs (if it doesn't, then there is something wrong with your implementation; if it does, there is something wrong with your understanding of the protocol, or you are blocked from using the server).
Alternatively, use a packet capture tool like Wireshark to look at what packets are being sent and received, and see if that shows the problem.