Reputation: 83
I am using github.com/mattn/go-xmpp/xmpp golang package to send the messages to ejabberd. This is working fine but sometime it gives random error
client error : expected success or failure, got error in http://etherx.jabber.org/streams
client error : unmarshal iq: expected element type iq but have error
client error : unmarshal features: expected element type features but have
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
}
Upvotes: 1
Views: 170