xaxes
xaxes

Reputation: 397

Connect to ActiveMQ via STOMP in Go

Trying to connect to ActiveMQ instance on AWS via github.com/go-stomp/stomp library.

The following code throws invalid command error:

func (s *STOMP) Init() error {
    netConn, err := stomp.Dial("tcp", "host:61614")
    if err != nil {
        return errors.Wrap(err, "dial to server")
    }

    s.conn = netConn

    return nil
}

Upvotes: 2

Views: 3305

Answers (1)

xaxes
xaxes

Reputation: 397

AmazonMQ uses stomp+ssl proto, so the proper way to connect to it is to setup TLS connection on your own first:

func (s *STOMP) Init() error {
    netConn, err := tls.Dial("tcp", "host:61614", &tls.Config{})
    if err != nil {
        return errors.Wrap(err, "dial tls")
    }
    stompConn, err := stomp.Connect(netConn)
    if err != nil {
        return errors.Wrap(err, "dial to server")
    }

    s.conn = stompConn

    return nil
}

https://github.com/go-stomp/stomp/wiki/Connect-using-TLS

Upvotes: 2

Related Questions