shadow1ng/fscan · error

activemq_stomp_send_failed: %w

Error message

activemq_stomp_send_failed: %w

What it means

authenticateSTOMP sends a STOMP CONNECT frame to ActiveMQ over the raw TCP connection. If conn.Write fails (connection reset, timeout expiry, broken pipe) the send error is wrapped as 'activemq_stomp_send_failed'.

Source

Thrown at plugins/services/activemq.go:170

		"login incorrect",
	}

	return ClassifyError(err, activeMQAuthErrors, CommonNetworkErrors)
}

// authenticateSTOMP 使用STOMP协议认证ActiveMQ
func (p *ActiveMQPlugin) authenticateSTOMP(conn net.Conn, username, password string, config *common.Config) (bool, error) {
	timeout := config.ModuleTimeout()
	if err := rejectLineBreaks(username, password); err != nil {
		return false, err
	}

	stompConnect := fmt.Sprintf("CONNECT\naccept-version:1.0,1.1,1.2\nhost:/\nlogin:%s\npasscode:%s\n\n\x00",
		username, password)

	_ = conn.SetWriteDeadline(time.Now().Add(timeout))
	if _, err := conn.Write([]byte(stompConnect)); err != nil {
		return false, fmt.Errorf("%s: %w", i18n.GetText("activemq_stomp_send_failed"), err)
	}

	_ = conn.SetReadDeadline(time.Now().Add(timeout))
	response := make([]byte, 1024)
	n, err := conn.Read(response)
	if err != nil {
		return false, fmt.Errorf("%s: %w", i18n.GetText("activemq_stomp_read_failed"), err)
	}
	if n == 0 {
		return false, fmt.Errorf("%s", i18n.GetText("activemq_stomp_empty_response"))
	}

	responseStr := string(response[:n])

	if strings.Contains(responseStr, "CONNECTED") {
		return true, nil
	} else if strings.Contains(responseStr, "ERROR") {
		errorMsg := i18n.GetText("activemq_stomp_auth_error")

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Increase the connection/write timeout passed to authenticateSTOMP
  2. Enable the STOMP transport on ActiveMQ (stomp:// 61613 connector)
  3. Check firewall/LB idle-timeout and keepalive settings
  4. Retry the connection; a transient reset may succeed on reconnect

Example fix

// before
_ = conn.SetWriteDeadline(time.Now().Add(timeout))
if _, err := conn.Write([]byte(stompConnect)); err != nil {
    return false, fmt.Errorf("%s: %w", i18n.GetText("activemq_stomp_send_failed"), err)
}
// after (retry once on transient write failure)
_ = conn.SetWriteDeadline(time.Now().Add(timeout))
if _, err := conn.Write([]byte(stompConnect)); err != nil {
    if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
        return false, fmt.Errorf("stomp send timed out after %v", timeout)
    }
    return false, fmt.Errorf("%s: %w", i18n.GetText("activemq_stomp_send_failed"), err)
}
Defensive patterns

Strategy: retry

Validate before calling

conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
if err != nil { return fmt.Errorf("cannot reach %s: %w", addr, err) }

Try / catch

_, err := conn.Write(frame)
if err != nil {
    var ne net.Error
    if errors.As(err, &ne) && ne.Timeout() { /* backoff and retry */ }
    return err
}

Prevention

When it happens

Trigger: The write deadline (timeout) expires before the CONNECT frame is sent, the broker or an intermediary closes the TCP connection, or the socket is otherwise broken at write time.

Common situations: Broker under load dropping connections, firewall silently killing idle sockets, timeout set too small for a slow WAN link, or STOMP transport not enabled so the server closes the socket immediately after connect.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/746ac2ce6b429b95. Report an issue: GitHub.