-
-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
producer.send() does not reconnect to broker when receiving an ETIMEDOUT error #919
Comments
I've tried to reproduce this myself using Toxiproxy to introduce a timeout between the client and the broker, but I haven't been able to get it to actually trigger the error. The branch is AFAIK, the socket timeout is decided by the operating system, with no real way to override it from within NodeJS. According to $ sysctl net.inet.tcp | grep keepinit
net.inet.tcp.keepinit: 75000 So I configure my client to talk to Toxiproxy and for Toxiproxy to proxy to the broker. I connect the client and produce once just to see that everything works. Then I introduce the timeout into the proxy, setting it to stop all data but not actually close the connection. If it's stopping keepalive packets, then I would expect an ETIMEDOUT after 75 seconds. Lines 67 to 110 in b209037
That's not what I'm seeing though. Instead, it sits for about 10 minutes waiting before it actually times out. And I don't get an ETIMEDOUT error, and the client tries to reconnect several times (looks like nested retriers): $ time node examples/producer.js
info: ┏ [Producer] Initialized proxy
info: ┃ [ 0] {
info: ┃ [ 1] "timestamp": "2020-10-14T13:36:40.312Z",
info: ┃ [ 2] "logger": "kafkajs",
info: ┃ [ 3] "proxy": {
info: ┃ [ 4] "toxiproxy": {
info: ┃ [ 5] "host": "http://192.168.0.38:8474"
info: ┃ [ 6] },
info: ┃ [ 7] "name": "kafka-proxy",
info: ┃ [ 8] "listen": "[::]:39094",
info: ┃ [ 9] "upstream": "kafka:29094",
info: ┃ [10] "enabled": true,
info: ┃ [11] "toxics": []
info: ┃ [12] }
info: ┗ [13] }
info: ┏ Sending 236 messages #0...
info: ┃ [0] {
info: ┃ [1] "timestamp": "2020-10-14T13:36:40.370Z",
info: ┃ [2] "logger": "kafkajs"
info: ┗ [3] }
info: ┏ Messages sent #0
info: ┃ [ 0] {
info: ┃ [ 1] "timestamp": "2020-10-14T13:36:40.468Z",
info: ┃ [ 2] "logger": "kafkajs",
info: ┃ [ 3] "response": [
info: ┃ [ 4] {
info: ┃ [ 5] "topicName": "topic-test",
info: ┃ [ 6] "partition": 0,
info: ┃ [ 7] "errorCode": 0,
info: ┃ [ 8] "baseOffset": "5878",
info: ┃ [ 9] "logAppendTime": "-1",
info: ┃ [10] "logStartOffset": "0"
info: ┃ [11] }
info: ┃ [12] ],
info: ┃ [13] "msgNumber": 236
info: ┗ [14] }
info: ┏ [Producer] Creating network timeout
info: ┃ [ 0] {
info: ┃ [ 1] "timestamp": "2020-10-14T13:36:40.472Z",
info: ┃ [ 2] "logger": "kafkajs",
info: ┃ [ 3] "toxic": {
info: ┃ [ 4] "attributes": {
info: ┃ [ 5] "timeout": 0
info: ┃ [ 6] },
info: ┃ [ 7] "name": "timeout_downstream",
info: ┃ [ 8] "stream": "downstream",
info: ┃ [ 9] "toxicity": 1,
info: ┃ [10] "type": "timeout"
info: ┃ [11] }
info: ┗ [12] }
info: ┏ Sending 573 messages #1...
info: ┃ [0] {
info: ┃ [1] "timestamp": "2020-10-14T13:36:40.473Z",
info: ┃ [2] "logger": "kafkajs"
info: ┗ [3] }
// ... Sits here for about 10 minutes
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:41.268Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:41.269Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 0,
error: ┃ [4] "retryTime": 335
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:41.275Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:42.608Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:42.608Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 1,
error: ┃ [4] "retryTime": 542
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:42.613Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:44.155Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:44.155Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 2,
error: ┃ [4] "retryTime": 964
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:44.160Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:46.120Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:46.121Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 3,
error: ┃ [4] "retryTime": 1864
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:46.125Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:48.991Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:48.992Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 4,
error: ┃ [4] "retryTime": 3810
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:48.995Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:53.804Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to broker, reconnecting
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:53.805Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 5,
error: ┃ [4] "retryTime": 7784
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:53.812Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "localhost:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:54.810Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:54.811Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 0,
error: ┃ [4] "retryTime": 249
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:54.815Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:56.064Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:56.065Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 1,
error: ┃ [4] "retryTime": 404
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:56.068Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:57.470Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:57.471Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 2,
error: ┃ [4] "retryTime": 748
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:57.475Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:59.227Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:59.227Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 3,
error: ┃ [4] "retryTime": 1220
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:46:59.232Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:01.449Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:01.450Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 4,
error: ┃ [4] "retryTime": 2494
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:01.454Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:04.952Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:04.952Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 5,
error: ┃ [4] "retryTime": 5136
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:04.959Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:05.956Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:05.957Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 0,
error: ┃ [4] "retryTime": 282
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:05.961Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:07.241Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:07.242Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 1,
error: ┃ [4] "retryTime": 564
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:07.246Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:08.814Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:08.814Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 2,
error: ┃ [4] "retryTime": 1092
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:08.819Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:10.917Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:10.918Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 3,
error: ┃ [4] "retryTime": 2474
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:10.928Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:14.398Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:14.399Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 4,
error: ┃ [4] "retryTime": 4666
error: ┗ [5] }
error: ┏ [Connection] Connection error: Client network socket disconnected before secure TLS connection was established
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:14.406Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer",
error: ┃ [5] "stack": "Error: Client network socket disconnected before secure TLS connection was established\n at connResetException (internal/errors.js:613:14)\n at TLSSocket.onConnectEnd (_tls_wrap.js:1545:19)\n at TLSSocket.emit (events.js:326:22)\n at endReadableNT (_stream_readable.js:1226:12)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"
error: ┗ [6] }
error: ┏ [Connection] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:20.071Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "broker": "192.168.0.38:39094",
error: ┃ [4] "clientId": "example-producer"
error: ┗ [5] }
error: ┏ [BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:20.071Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "retryCount": 5,
error: ┃ [4] "retryTime": 10370
error: ┗ [5] }
error: ┏ [example/producer] Connection timeout
error: ┃ [0] {
error: ┃ [1] "timestamp": "2020-10-14T13:47:20.072Z",
error: ┃ [2] "logger": "kafkajs",
error: ┃ [3] "stack": "KafkaJSNonRetriableError\n Caused by: KafkaJSNonRetriableError\n Caused by: KafkaJSConnectionError: Connection timeout\n at Timeout.onTimeout [as _onTimeout] (/Users/tommybrunn/workspace/kafkajs/src/network/connection.js:165:23)\n at listOnTimeout (internal/timers.js:551:17)\n at processTimers (internal/timers.js:494:7)"
error: ┗ [4] }
info: ┏ process.on SIGTERM
info: ┃ [0] {
info: ┃ [1] "timestamp": "2020-10-14T13:47:20.072Z",
info: ┃ [2] "logger": "kafkajs"
info: ┗ [3] }
node examples/producer.js 0.59s user 0.13s system 0% cpu 10:40.30 total Another option might be to write a test where you implement a custom socket factory with a socket that you can trigger to emit the |
I'll try to reproduce with toxiproxy and/or a custom socket factory today, since I'd like to figure this out. I think if I'm not able to reproduce in a timely fashion, I'm going to turn off kafkajs retries altogether and just catch and retry myself. |
Based on my testing yesterday, I'm not sure there's a way to work around this without shutting off retries altogether. The code as currently written closes down the socket connection to a single broker, not the entire connection, so even if I implement a custom socket factory and listen for |
Can you share a link to what you're referring to? I would have expected this to come via the socket |
Hello, I've made an attempt to reproduce the issue using docker, see below: Test descriptionEnvironment:KafkaJS version 1.15.0 How to runJust run the script What the script doesIt starts a zookeeper + 3 brokers + control-center The producer code is very simple. Config used is: const kafka = new Kafka({
clientId: 'my-kafkajs-producer',
brokers: ['broker1:9092','broker2:9092','broker3:9092'],
enforceRequestTimeout: true,
logLevel: logLevel.DEBUG,
acks:1,
connectionTimeout: 20000,
}) It allows only one pending request in order to make troubleshooting easier. I'm blocking IP address (using iptables) corresponding to kafkaJS client container in
let the test run 5 minutes
Unblocking IP address $ip corresponding to kafkaJS client
let the test run 5 minutes
ResultsTest with 10 minutes connection errorTraffic is blocked at
30 seconds later request timeout:
Then we see a
That seems to trigger a disconnect:
I do not see a re-connect, but requests are retried: Retries:
etc... Note: Request metadata happening on broker3, broker1 is seen as ok as expected (because connection issue is only happening from broker1 to kakfaJS client):
At
We see a disconnection, probably because broker disconnected for good the client (due to
Full logs are here Test with 5 minutes connection errorI re-ran a test with 5 minutes of iptables instead of 10 minutes (to avoid the disconnection from the broker due to Traffic was blocked at
Around 60 seconds later we see disconnection:
When traffic is back at
We see a retry right after:
After 21 seconds (not sure why??), we see accumulated responses (blocked by iptables)
Followed by request response:
So even if there was a disconnection, it seems that kafkaJS is able to send request again when connection is back ? Full logs are here |
Describe the bug
A lambda I'm running will occasionally receive an ETIMEDOUT error when producing messages to Kafka. When this happens, kafkajs disconnects from the broker and never reconnects, but will continue to retry sending the messages.
To Reproduce
Unfortunately I cannot link to sample code or give you a way to reproduce this reliably (maybe someone reading this can guide me toward a way of forcing an ETIMEDOUT error?), but I will explain our setup with as much code as I can. We're not doing anything too strange here, just setting it up and producing messages.
We configure the kafka object with the following:
and then the producer, nothing wild here:
Expected behavior
I expect this to disconnect from the broker, try to reconnect to the broker, and if it successfully does that, start retrying the messages.
Observed behavior
tl;dr the timeout error happens, kafkajs disconnects from the broker, messages are retried without reconnecting to the broker.
This code is running in an aws lambda and happily chugs along doing what it should for awhile, then we receive an ETIMEDOUT error while producing. Log looks like the following:
after this, with debug logging turned on, we see the following logs:
[Connection] disconnecting...
[RequestQueue] Waiting for pending requests
[Connection] Kafka server has closed connection
[Connection] disconnecting...
[Connection] disconnected
[Connection] Request Metadata(key: 3, version: 5)
[Connection] Request Metadata(key: 3, version: 5)
[Connection] Request Metadata(key: 3, version: 5)
(presumably the 3 last lines are one request to each of the 3 brokers) and then the lambda times out.
EDIT: the 3 last lines are actually just 3 retries to 1 broker, and they happen a few seconds apart from each other
Environment:
Additional context
I have dug around in the code quite a bit trying to understand what's going on here and these are my findings, unclear whether they're actually useful, but here they are.
There are retriers at several levels of the stack, I found them in
connection.js
(although this one seems to be unused?),cluster/index.js
,messageProducer.js
,producer/index.js
andsendMessages.js
. The retrier inmessageProducer.js
is not created withcreateRetry
and includes code to actually reconnect to the broker if it's disconnected (great!), but afaict the retrier insendMessages.js
catches this error first and retries the messages without attempting a reconnect to the cluster. Honestly though, any of the retries further down the stack other than the one insendMessages.js
could be what's catching it, they all use the generic retrier fromcreateRetry
.Also, in my attempts to work around what I saw as the problem, I added a disconnect listener to my code that listens for disconnects and tries to reinitiate the connection, but the
DISCONNECT
event never seems to fire (based on logging toproducer.logger().info()
I set up in the listener) when the ETIMEDOUT error happens, so the listener does not get a chance to do its job. I have tests in my codebase to trigger theDISCONNECT
event and this code does what I'd expect it to in those tests. Code for the listener follows:The text was updated successfully, but these errors were encountered: