Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Link can't be closed #172

Open
qiulian111 opened this issue Sep 16, 2019 · 6 comments
Open

Link can't be closed #172

qiulian111 opened this issue Sep 16, 2019 · 6 comments

Comments

@qiulian111
Copy link

Hi, dear:
I called the function link.Close(ctx), and the link ( send or receive link) didn't be closed, the thread of this link still run in background ,it leads to memory full . please help me ,thanks
ps : I didn't close the session of link

@vcabbage
Copy link
Owner

Can you please provide some details about what you're seeing? Closing a link does a graceful close, if the broker doesn't respond with the appropriate detach the goroutine will hang until the session/conn is terminated.

If you'd like to provide debug logging (https://github.com/vcabbage/amqp/blob/master/CONTRIBUTING.md#logging) I can take a look to see if that's what's happening here.

@qiulian111
Copy link
Author

Hi:
I'm using rabbitmq v3.7.18, when i try to close the sender ,it shows "context deadline exceeded"
here is my source code :

package main
import (
"log"
"time"
"pack.ag/amqp"
"context"
)
func main() {
ctx := context.Background()
testCancel(ctx)
}
func testCancel(ctx context.Context) error{
data := []byte("abc")
req := amqp.NewMessage(data)
req.Header = &amqp.MessageHeader{ TTL: time.Duration(30000)*time.Millisecond }
req.Properties = &amqp.MessageProperties{}
req.Properties.MessageID = "abcd"
req.Properties.ReplyTo = "abcd"
req.Properties.To = "to"
req.Properties.Subject = "test"
client, err := amqp.Dial("amqp://192.168.8.6:5672" , amqp.ConnSASLPlain("data_user", "jwi_gogogo"),amqp.ConnIdleTimeout(0) )
session, err := client.NewSession(
amqp.SessionIncomingWindow(65535),
amqp.SessionOutgoingWindow(65535),
)
sender, err := session.NewSender(
amqp.LinkTargetAddress( "target_test"),
)
myctx, cancel := context.WithTimeout(ctx, time.Duration(5)time.Second)
err = sender.Send(myctx, req)
cancel()
if(sender!= nil){
sctx, sctx_cancel := context.WithTimeout(ctx, 10
time.Second)
err = sender.Close(sctx) // error : context.deadlineExceededError
log.Println(err)
sctx_cancel()
}
return err
}

and here is the log info.:
11:30:37.154934 TX: Begin{RemoteChannel: 0, NextOutgoingID: 0, IncomingWindow: 65535, OutgoingWindow: 65535, HandleMax: 4294967295, OfferedCapabilities: [], DesiredCapabilities: [], Properties: map[]}
11:30:37.188535 RX: Begin{RemoteChannel: 0, NextOutgoingID: 0, IncomingWindow: 65535, OutgoingWindow: 65535, HandleMax: 4294967295, OfferedCapabilities: [], DesiredCapabilities: [], Properties: map[]}
11:30:37.188535 TX: Attach{Name: JkEe_BJuRRgpym-W9f3wDhcnq-uCs2OhE3Tyk-8SqpsWtPc5gqM5-w, Handle: 0, Role: Sender, SenderSettleMode: , ReceiverSettleMode: , Source: , Target: source{Address: target_test, Durable: 0, ExpiryPolicy: , Timeout: 0, Dynamic: false, DynamicNodeProperties: map[], Capabilities: []}, Unsettled: map[], IncompleteUnsettled: false, InitialDeliveryCount: 0, MaxMessageSize: 0, OfferedCapabilities: [], DesiredCapabilities: [], Properties: map[]}
11:30:37.188535 RX(Session): Attach{Name: JkEe_BJuRRgpym-W9f3wDhcnq-uCs2OhE3Tyk-8SqpsWtPc5gqM5-w, Handle: 0, Role: Receiver, SenderSettleMode: , ReceiverSettleMode: , Source: , Target: source{Address: target_test, Durable: 0, ExpiryPolicy: session-end, Timeout: 0, Dynamic: false, DynamicNodeProperties: map[], Capabilities: []}, Unsettled: map[], IncompleteUnsettled: false, InitialDeliveryCount: 0, MaxMessageSize: 0, OfferedCapabilities: [], DesiredCapabilities: [], Properties: map[]}
11:30:37.188535 RX(Session): Flow{NextIncomingID: 0, IncomingWindow: 65535, NextOutgoingID: 0, OutgoingWindow: 65535, Handle: 0, DeliveryCount: , LinkCredit: 65536, Available: , Drain: false, Echo: false, Properties: map[]}
11:30:37.188535 RX(Session): Disposition{Role: Receiver, First: 1, Last: 1, Settled: true, State: Accepted, Batchable: false}
11:30:37.188535 TX(Session): Detach{Handle: 0, Closed: true, Error: *Error(nil)}
11:30:37.188535 RX(Session): Detach{Handle: 0, Closed: false, Error: *Error(nil)}
2019/09/25 11:30:47 context deadline exceeded

@vcabbage
Copy link
Owner

Thank you. This is indeed a broker issue. Described here #60 (comment) and the issue in the upstream repo https://github.com/rabbitmq/rabbitmq-amqp1.0/issues/60.

@qiulian111
Copy link
Author

Thank you , can you provide a temporary solution to avoid this issue? It seems that their progress is very slow.

@vcabbage
Copy link
Owner

The workaround is to close the session and/or connection.

@umohank
Copy link

umohank commented May 27, 2020

Temporary queue created by createReceiver, is not deleting.
receiver.close call is blocking.
tried with workaround, closing session and connection didn't work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants