1. Benjamin Smith
  2. python-stomp
  3. Issues
Issue #6 resolved

Does disconnect not work?

Tristan Zajonc
created an issue

It seems that disconnect is not working. Here's what I get, python 2.6.4/OSX connecting to Orbited/RabbitMQ.

{{{

!python

import stompy stomp = stompy.Client() stomp.connect() stomp.disconnect() stomp.connect() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "stompy/simple.py", line 95, in connect self.stomp.connect(username=username, password=password) File "stompy/stomp.py", line 51, in connect raise self.ConnectionError(*exc.args) stompy.stomp.ConnectionError: [Errno 56] Socket is already connected }}}

Comments (4)

  1. Benjamin Smith repo owner

    This was resolved long ago.. Relevant code:

        def connect(self, username=None, password=None, clientid=None):
            """Connect to STOMP server.
                
            :keyword username: Username for connection
            :keyword password: Password for connection
            :keyword clientid: Client identification for persistent connections
            """
            try:
                self.sock.connect((self.host, self.port))
                self.frame.connect(self.sock, username=username, password=password, clientid=clientid)
            except socket.timeout, exc:
                raise self.ConnectionTimeoutError(*exc.args)
            except socket.error, exc:
                raise self.ConnectionError(*exc.args)
            self.connected = True
                
        def disconnect(self, conf=None):
            """Disconnect from the server."""
            try:
                for destination in self._subscribed_to.keys():
                    self.unsubscribe({"destination": destination})
                self._send_command("DISCONNECT", conf)
            except self.NotConnectedError:
                pass
            try:
                self.sock.shutdown(0)
                self.sock.close()
            except socket.error, exc:
                # likely wasn't connected
                pass
            self.connected = False
    
  2. Log in to comment