{"record":{"id":"746ac2ce6b429b95","repo":"shadow1ng/fscan","slug":"activemq-stomp-send-failed-w","errorCode":null,"errorMessage":"activemq_stomp_send_failed: %w","messagePattern":"activemq_stomp_send_failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/activemq.go","lineNumber":170,"sourceCode":"\t\t\"login incorrect\",\n\t}\n\n\treturn ClassifyError(err, activeMQAuthErrors, CommonNetworkErrors)\n}\n\n// authenticateSTOMP 使用STOMP协议认证ActiveMQ\nfunc (p *ActiveMQPlugin) authenticateSTOMP(conn net.Conn, username, password string, config *common.Config) (bool, error) {\n\ttimeout := config.ModuleTimeout()\n\tif err := rejectLineBreaks(username, password); err != nil {\n\t\treturn false, err\n\t}\n\n\tstompConnect := fmt.Sprintf(\"CONNECT\\naccept-version:1.0,1.1,1.2\\nhost:/\\nlogin:%s\\npasscode:%s\\n\\n\\x00\",\n\t\tusername, password)\n\n\t_ = conn.SetWriteDeadline(time.Now().Add(timeout))\n\tif _, err := conn.Write([]byte(stompConnect)); err != nil {\n\t\treturn false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_send_failed\"), err)\n\t}\n\n\t_ = conn.SetReadDeadline(time.Now().Add(timeout))\n\tresponse := make([]byte, 1024)\n\tn, err := conn.Read(response)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_read_failed\"), err)\n\t}\n\tif n == 0 {\n\t\treturn false, fmt.Errorf(\"%s\", i18n.GetText(\"activemq_stomp_empty_response\"))\n\t}\n\n\tresponseStr := string(response[:n])\n\n\tif strings.Contains(responseStr, \"CONNECTED\") {\n\t\treturn true, nil\n\t} else if strings.Contains(responseStr, \"ERROR\") {\n\t\terrorMsg := i18n.GetText(\"activemq_stomp_auth_error\")","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/activemq.go#L152-L188","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Increase the connection/write timeout passed to authenticateSTOMP","Enable the STOMP transport on ActiveMQ (stomp:// 61613 connector)","Check firewall/LB idle-timeout and keepalive settings","Retry the connection; a transient reset may succeed on reconnect"],"exampleFix":"// before\n_ = conn.SetWriteDeadline(time.Now().Add(timeout))\nif _, err := conn.Write([]byte(stompConnect)); err != nil {\n    return false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_send_failed\"), err)\n}\n// after (retry once on transient write failure)\n_ = conn.SetWriteDeadline(time.Now().Add(timeout))\nif _, err := conn.Write([]byte(stompConnect)); err != nil {\n    if netErr, ok := err.(net.Error); ok && netErr.Timeout() {\n        return false, fmt.Errorf(\"stomp send timed out after %v\", timeout)\n    }\n    return false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_send_failed\"), err)\n}","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", addr, 5*time.Second)\nif err != nil { return fmt.Errorf(\"cannot reach %s: %w\", addr, err) }","typeGuard":null,"tryCatchPattern":"_, err := conn.Write(frame)\nif err != nil {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() { /* backoff and retry */ }\n    return err\n}","preventionTips":["Set realistic write deadlines for the network path","Enable STOMP transport on the target broker","Use TCP keepalives to avoid silently dropped connections","Retry transient write failures with backoff"],"tags":["network","stomp","activemq"],"backgroundTag":"broken-pipe","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}