Xmpp client error auth failure: Nonce mismatch

64 Views Asked by At

I am using github.com/mattn/go-xmpp/xmpp golang package to send the messages to ejabberd. I have added a valid user and messages are sent but sometimes it gives error :auth failure: Nonce mismatch. This error is occur while multiple user send request at a time. Please help me to resolve this error.

My code is given below:

package main

import (

    "log"
    "time"
    "github.com/mattn/go-xmpp/xmpp"
)

func main() {

    options := xmpp.Options{
        Host:      "your_ejabberd_host",
        User:      "your_username",
        Password:  "your_password",
        Debug:     true,
        NoTLS:     false,
        DialTimeout: time.Second * 10,
    }

    conn, err := options.NewClient()
    if err != nil {
        log.Fatal("Failed to create XMPP client:", err)
    }

    // Send a sample message
    err = conn.Send(xmpp.Chat{
        Remote: "[email protected]",
        Type:   "chat",
        Text:   "Hello, this is a test message!",
    })
    if err != nil {
        log.Fatal("Failed to send message:", err)
    }
    conn.Close()
    return
}
0

There are 0 best solutions below