Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ func (c *Client) Resume() error {
// Disconnect disconnects the client from the server, sending a stream close nonza and closing the TCP connection.
func (c *Client) Disconnect() error {
if c.transport != nil {
return c.transport.Close()
err := c.transport.Close()
if c.Session != nil {
c.disconnected(c.Session.SMState)
}
return err
}
// No transport so no connection.
return nil
Expand Down Expand Up @@ -411,7 +415,8 @@ func (c *Client) recv(keepaliveQuit chan<- struct{}) {
case stanza.StreamClosePacket:
// TCP messages should arrive in order, so we can expect to get nothing more after this occurs
c.transport.ReceivedStreamClose()
return
c.Disconnect()
continue
default:
c.Session.SMState.Inbound++
}
Expand Down
5 changes: 4 additions & 1 deletion xmpp_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ var clientStreamOpen = fmt.Sprintf("<?xml version='1.0'?><stream:stream to='%%s'
func (t *XMPPTransport) Connect() (string, error) {
var err error

// Since we're starting a new connection, reset the encryption status
t.isSecure = false

t.conn, err = net.DialTimeout("tcp", t.Config.Address, time.Duration(t.Config.ConnectTimeout)*time.Second)
if err != nil {
return "", NewConnError(err, true)
}

t.closeChan = make(chan stanza.StreamClosePacket)
t.closeChan = make(chan stanza.StreamClosePacket, 1)
t.readWriter = newStreamLogger(t.conn, t.logFile)
t.decoder = xml.NewDecoder(bufio.NewReaderSize(t.readWriter, maxPacketSize))
t.decoder.CharsetReader = t.Config.CharsetReader
Expand Down