streadway / amqp

Go client for AMQP 0.9.1
http://godoc.org/github.com/streadway/amqp
BSD 2-Clause "Simplified" License
4.88k stars 621 forks source link

failed to dail() when password contains with special characters like "#" #522

Open devloper999 opened 2 years ago

devloper999 commented 2 years ago

Similar to issue mentioned in the thread : https://github.com/streadway/amqp/issues/416 Hi, I am facing the same issue in the above thread with amqp.Dial, if the username or password has "#" symbol, then the split happen at # internally in the Dial code. Can someone please help how to resolve this. I tried even query escape but no luck. Code inside amqp Dial method : url.Parse splits at # and it is causing the invalidPort error. func Parse(rawURL string) (*URL, error) { // Cut off #frag u, frag := split(rawURL, '#', true)

Below is the code snippet func connectToRMQServer() { fmt.Println("Connection staretd ") rmqurl := "amqp://guest:" + url.QueryEscape("guest#") + "@localhost:5672/" fmt.Println("rmqurl ", rmqurl) conn, err := amqp.Dial(rmqurl) if err != nil { fmt.Println("Error is ", "Failed to connect to RabbitMQ", err) return } fmt.Println("Connection succesful ", conn) } func main() { fmt.Println("in main") connectToRMQServer() }