I have read the other questions and I have found no answer...
I have three services deployed in kubernetes: one service that sends messages, one broker and one consumer. The broker and the consumer connect perfectly, but the sender and the broker don't connect.
My sender is in C#, using the NetMQ
library, and my broker and my consumer are in Node, using the zeromq
library.
My sender binds like this:
public sealed class ZeroMQProvider : IZeroMQProvider, IDisposable{ private readonly PushSocket _socket; private readonly ILogger<ZeroMQProvider> _logger; private readonly TimeSpan _sendTimeout; public ZeroMQProvider(IConfiguration configuration, ILogger<ZeroMQProvider> logger) { _socket = new PushSocket($"@tcp://{configuration["ZEROMQ_HOST"]}:{configuration["ZEROMQ_PORT"]}"); _logger = logger; _sendTimeout = TimeSpan.FromMilliseconds(Convert.ToInt32(configuration["ZEROMQ_TIMEOUT_MS"])); } public void Dispose() { _socket.Dispose(); } public Result SendMessage(string message) { try { bool success = _socket.TrySendFrame(timeout: _sendTimeout, message: message); if (!success) { return Result.Fail(new BrokerError()); } return Result.Ok(); } catch (Exception ex) { _logger.LogError("{Msg}", ex.Message); _logger.LogError("{Strace}", ex.StackTrace); return Result.Fail(new BrokerError()); } }}
My broker connects like this:
var checkerSocket = new zmq.Pull({connectTimeout: 2000}); try { checkerSocket.events.on('connect:retry', e => { console.log(new Date(), e.type); }); console.log(`BIND: tcp://${config.zeromq.checker.CHECKER_HOST}:${config.zeromq.checker.CHECKER_PORT}`); checkerSocket.connect(`tcp://${config.zeromq.checker.CHECKER_HOST}:${config.zeromq.checker.CHECKER_PORT}`);
Note that this works in docker-compose
but not in Kubernetes, but the addresses are well set and all. The TCP socket is in SYN_SEND
state and won't move from there. I have also tried to reverse the roles, but it also works on docker-compose
but not in Kubernetes in AWS.
Any ideas?