5

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.

asked Dec 8, 2012 at 22:03
2
  • 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. Commented 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). Commented Dec 8, 2012 at 22:23

1 Answer 1

2

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.

answered Dec 8, 2012 at 22:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.