lockdm / ibpy

Automatically exported from code.google.com/p/ibpy
Other
0 stars 0 forks source link

disconnect and re-connect failure #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call connection.connect()
2. call connection.disconnect()
3. call connection.connect()

What is the expected output? What do you see instead?
It is expect to connect fine in step 3. But instead I got ## error: 
code=326  message=Unable connect as the client id is already in use. Retry
with a unique client id. 

What version of the product are you using? On what operating system?
r290. Debian GNU/Linux.

Please provide any additional information below.

Original issue reported on code.google.com by yichun....@gmail.com on 7 Jan 2008 at 1:16

GoogleCodeExporter commented 9 years ago
It is because TWS doesn't immediately end the conversation after  

ib/ext/EClientSocket.py line 168:
m_socket.close() 

If we have

m_socket.shutdown(socket.SHUT_RDWR)
m_socket.close() 

then the TWS should end the conversation immediately, and subsequent connection 
will
work just fine.

Original comment by yichun....@gmail.com on 7 Jan 2008 at 1:19

GoogleCodeExporter commented 9 years ago
According to
http://www.amk.ca/python/howto/sockets/sockets.html#SECTION000500000000000000000

"""Strictly speaking, you're supposed to use shutdown on a socket before you 
close
it. The shutdown is an advisory to the socket at the other end. Depending on the
argument you pass it, it can mean "I'm not going to send anymore, but I'll still
listen", or "I'm not listening, good riddance!". Most socket libraries, 
however, are
so used to programmers neglecting to use this piece of etiquette that normally a
close is the same as shutdown(); close(). So in most situations, an explicit 
shutdown
is not needed.
"""

Python's socket module might do things more politely. Of course I do not know 
what
happens when java client called socket.close(), but seems it may not need a
.shutdown()...

Original comment by yichun....@gmail.com on 7 Jan 2008 at 3:22

GoogleCodeExporter commented 9 years ago
Fix in r292, needs verification.

Original comment by troy.mel...@gmail.com on 5 Feb 2008 at 8:48

GoogleCodeExporter commented 9 years ago
Closing without verification.

Original comment by troy.mel...@gmail.com on 11 May 2008 at 3:23