{"record":{"id":"2684166c7e6a7567","repo":"risingwavelabs/risingwave","slug":"nats-error-0","errorCode":null,"errorMessage":"Nats error: {0}","messagePattern":"Nats error: (.+?)","errorType":"exception","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/mod.rs","lineNumber":1142,"sourceCode":"        anyhow::Error,\n    ),\n    #[error(\"ClickHouse error: {0}\")]\n    ClickHouse(String),\n    #[error(\"Redis error: {0}\")]\n    Redis(String),\n    #[error(\"Http error: {0}\")]\n    Http(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n    #[error(\"Mqtt error: {0}\")]\n    Mqtt(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n    #[error(\"Nats error: {0}\")]\n    Nats(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n    #[error(\"Google Pub/Sub error: {0}\")]\n    GooglePubSub(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n    #[error(\"Doris/Starrocks connect error: {0}\")]\n    DorisStarrocksConnect(\n        #[source]\n        #[backtrace]\n        anyhow::Error,\n    ),\n    #[error(\"Doris error: {0}\")]","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/mod.rs#L1124-L1160","documentation":"SinkError::Nats(anyhow::Error) in src/connector/src/sink/mod.rs:1143 wraps failures from the NATS sink connector, keeping the source anyhow::Error and backtrace from the NATS client. Raised when establishing a connection to the NATS server, authenticating, or publishing to a subject fails.","triggerScenarios":"CREATE SINK ... WITH (connector='nats') when: the server URL is wrong or unreachable, authentication/authorization fails (credentials file, token, or user/pass), TLS handshake fails, or a publish fails (max payload exceeded, no responders for request-reply, connection closed).","commonSituations":"nats:// vs tls:// scheme mismatch; expired or rotated NATS credentials (nsc operator account); server max_payload smaller than the encoded sink message; NATS server restarted and sink did not reconnect cleanly.","solutions":["Verify connectivity with nats --server <url> pub test hi (and matching creds) and correct the server URL/credentials in the sink options.","Check auth configuration: token, user/password, or .creds file path and freshness.","Compare message size against the server's max_payload (INFO) and reduce the encoded payload if it exceeds the limit.","Fix the URL scheme (nats:// vs tls://) and provide CA material if TLS is required.","Inspect the wrapped NATS client error in RisingWave logs to pinpoint connect vs publish stage."],"exampleFix":"// before: publish exceeds server max_payload\nCREATE SINK nats_sink FROM mv WITH (\n  connector = 'nats', server_url = 'nats://nats:4222', subject = 'rw.events'\n);\n// after: reduce encoded row size or raise server max_payload\nCREATE SINK nats_sink FROM mv WITH (\n  connector = 'nats', server_url = 'nats://nats:4222', subject = 'rw.events',\n  format = 'append only', encode = 'json'\n);","handlingStrategy":"retry","validationCode":"# Verify NATS server, auth, and payload limits before creating the sink\nnats --server \"$NATS_URL\" --creds creds.creds pub rw.health check\nnats --server \"$NATS_URL\" server info | grep -i max_payload","typeGuard":"fn is_valid_nats_url(url: &str) -> bool {\n    url.starts_with(\"nats://\") || url.starts_with(\"tls://\")\n}","tryCatchPattern":"// Reconnect on transient errors; fail fast on authz errors\nmatch sink_result {\n    Err(SinkError::Nats(e)) if is_transient(&e) => retry_with_backoff(),\n    Err(SinkError::Nats(e)) if is_authz(&e) => fix_credentials_and_restart_sink(),\n    Err(e) => alert(&e.to_string()),\n    Ok(v) => process(v),\n}","preventionTips":["Pre-flight publish with the nats CLI using the exact credentials the sink will use","Keep encoded messages under the server's max_payload limit","Use tls:// scheme and CA config when the server requires TLS","Rotate nsc credentials with overlap and update sink definitions promptly","Monitor NATS server restarts and configure sink reconnect behavior"],"tags":["nats","sink","network","risingwave-connector"],"backgroundTag":"network-request-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}