Skip to content

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

Description

@devloper999

Similar to issue mentioned in the thread : #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()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions