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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With