What causes DNS responses with an unknown ID? - dns

I'm using vert.x 3.7.1, which depends on netty 4.1.34.Final. HTTP requests are being made through vertx-web.
WebClient client = WebClient.create(vertx);
HttpRequest<JsonArray> request = client.postAbs(uri)
.timeout(timeout)
.basicAuthentication(username, password)
.as(BodyCodec.jsonArray());
// HttpRequest is created once and used for several requests.
request.sendJsonObject(bodyJson, handler);
Some times, netty logs the following warning. It repeats every 5 seconds with a different id and stops when DNS resolves, I believe.
WARNING [io.netty.resolver.dns.DnsNameResolver] [id: 0xf9a6e215, L:/0.0.0.0:37175] Received a DNS response with an unknown ID: 38649
As I understand, netty generates a random id for the DNS query datagram and stores it as a key for the DNS query context in a map. When the DNS response datagram is received, the id is retrieved and checked against the map. When the DNS process finishes, the id is removed from the map.
What causes a DNS Response datagram to have an unknown id? Does that log indicate some problem? Should I take it as a regular event?

Related

Azure Cosmos DB: 503 Service Unavailable

While connecting from my code outside of the company network, the Cosmos DB connection works just fine. But from the company network, it throws a 503 ServiceUnavailable status code. What are the possible issues?
Based on the comments:
System.Exception: 'Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: ServiceUnavailable (503); Substatus: 0;
ActivityId: ;
Reason: (The request failed because the client was unable to establish connections to 4 endpoints across 1 regions. Please check for client resource starvation issues and verify connectivity between client and server.
Normally, if you take that exception and store or view the ToString(), it will show you more information. But from the message itself, it means the client tried to connect to all known endpoints available and failed.
This normally means there is either something on the network blocking your request or the machine executing this code is completely overloaded (CPU at 100% or port exhaustion) and cannot process any request.
If this is consistently failing for all operations, check that your network has the correct port range open:
By default, the SDK works in Direct mode, so check that ports in the 10000 through 20000 range are open and available. If you have private endpoint enabled, the range is 0 to 65535.
As #GauravMantri mentioned, you can change to Gateway mode also if the network is restricted:
string connectionString = "<your-account-connection-string>";
CosmosClient client = new CosmosClient(connectionString,
new CosmosClientOptions
{
ConnectionMode = ConnectionMode.Gateway
});

Kafka enabled Azure Event Hub: Invalid session timeout in Receiver

I'm trying to use the exact code provided here to send/receive data from a Kafka enabled Azure Event Hub.
https://github.com/Azure/azure-event-hubs-for-kafka/tree/master/quickstart/dotnet/EventHubsForKafkaSample
I'm successful in sending messages to the event hub, but each time I try to initialize the receiver, I get this invalid session timeout error.
7|2018-11-14 19:10:52.967|ssarkar#consumer-1|SEND| [thrd:sasl_ssl://ssarkar-test.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ssarkar-test.servicebus.windows.net:9093/0: Sent JoinGroupRequest (v0, 109 bytes # 0, CorrId 6)
7|2018-11-14 19:10:52.992|ssarkar#consumer-1|RECV| [thrd:sasl_ssl://ssarkar-test.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ssarkar-test.servicebus.windows.net:9093/0: Received JoinGroupResponse (v0, 16 bytes, CorrId 6, rtt 24.28ms)
7|2018-11-14 19:10:52.992|ssarkar#consumer-1|REQERR| [thrd:main]: sasl_ssl://ssarkar-test.servicebus.windows.net:9093/0: JoinGroupRequest failed: Broker: Invalid session timeout: actions Permanent
The only timeout I am specifying is the request.timeout.ms, and I have tried without that as well, but the error won't go away. I have also tried using various values of session.timeout.ms and still the error persists.
There is some info online about making sure that the session timeout value falls within the min and max of the group timeout value. But I don't have a way to view the broker configs on Azure Event Hub, so I have no idea what they are supposed to be.
EH allows session timeouts between 6000 ms and 300000 ms. We also reject your join group request if the request's rebalance timeout is less than session timeout.
Quick note - we aren't actually running real Kafka brokers, so there is a bit of added complexity to exposing broker configs. However, we will update our Github repository with configuration values/ranges!
11/22/19 edit - configuration doc can be found here https://github.com/Azure/azure-event-hubs-for-kafka/blob/master/CONFIGURATION.md

Rebus - Send delayed message to another queue (Azure ServiceBus)

I have a website and and a webjob, where the website is a oneway client and the webjob is worker.
I use the Azure ServiceBus transport for the queue.
I get the following error:
InvalidOperationException: Cannot use ourselves as timeout manager
because we're a one-way client
when I try to send Bus.Defer from the website bus.
Since Azure Servicebus have built in support for timeoutmanager should not this work event from a oneway client?
The documentation on Bus.Defer says: Defers the delivery of the message by attaching a header to it and delivering it to the configured timeout manager endpoint
/// (defaults to be ourselves). When the time is right, the deferred message is returned to the address indicated by the header."
Could I fix this by setting the ReturnAddress like this:
headers.Add(Rebus.Messages.Headers.ReturnAddress, "webjob-worker");
Could I fix this by setting the ReturnAddress like this: headers.Add(Rebus.Messages.Headers.ReturnAddress, "webjob-worker");
Yes :)
The problem is this: When you await bus.Defer a message with Rebus, it defaults to return the message to the input queue of the sender.
When you're a one-way client, you don't have an input queue, and thus there is no way for you to receive the message after the timeout has elapsed.
Setting the return address fixes this, although I admit the solution does not exactly reek of elegance. A nicer API would be if Rebus had a Defer method on its routing API, which could be called like this:
var routingApi = bus.Advanced.Routing;
await routingApi.Defer(recipient, TimeSpan.FromSeconds(10), message);
but unfortunately it does not have that method at the moment.
To sum it up: Yes, setting the return address explicitly on the deferred message makes a one-way client capable of deferring messages.

Http Inbound Gateway takes 2x timeout to send timeout response to client

We're using an http inbound gateway to process http requests. Lately , we wanted to set specific http response code that will be sent to user after a timeout.
We upgraded to spring 4.2.1 and set
the reply-timeout-status-code-expression attribute
and it's working now.
But there is a problem : if we set the timeout to 10 seconds , a ReplyTimeoutException is raised in the web application after exactly 10 seconds but the response arrives to the client after 20 seconds ( exactly the double ).
We changed the timeout several times but it always take 2x timeout for the response to be received by client.
This is the xml config for the http inbound gateway :
<int-http:inbound-gateway id="inboundRequest" request-channel="inbound-channel"
supported-methods="POST" path="/Request" error-channel="errorChannel" reply-channel="gateway_response"
reply-timeout="5000" request-payload-type="java.lang.String" reply-timeout-status-code-expression="'504'" >
A Help would be really appreciated
I see you have an error-channel - if the error flow returns no response, the reply timer starts again when the error flow ends (we're waiting for a reply from the error flow).
Instead of returning nothing from the error flow, you need to throw a MessageTimeoutException.
Turning on DEBUG logging and following the message flow is the best way to diagnose issues like this.
If that's not the problem, you need to show the rest of your configuration (edit the question, don't try to post it in a comment).

Spring Integration - TCP - Response Correlation

I'm new to Spring Integration. The situation is that I've to connect to Tcp server dynamically(i.e. the DNS will be dynamically generated at runtime based on some params). Because of this I'm using Service Activator to manually create Tcp Connections and send messages. I've overridden CachingClientConnectionFactory to make use of shared connections concept(with single-use='false'). I was listening to messages using TcpReceivingChannelAdaptor by overriding "onMessage" method. The problem is that the server either responds with a Success or failure(with Generic messages) with no CorrelationID. Is there any way to correlate the request with the response ?
I tried using TcpOutboundGateway, but with this approach also I get the same problem. I used TcpConnectionSupport to send messages :
//Sample Code.
final String correlationId = "" // Dynamic unique number
TcpOutboundGateway outboundGateway = new TcpOutboundGateway(){
public synchronized boolean onMessage(Message<?> message) {
ByteArrayToStringConverter converter = new ByteArrayToStringConverter();
String response = converter.convert((byte[]) message
.getPayload());
logger.info(correlationId);
return false;
}
};
DefaultCachingClientConnectionFactory connFactory = new DefaultCachingClientConnectionFactory();
TcpConnectionSupport con = connFactory.obtainConnection();
GenericMessage<String> msg = new GenericMessage<String>("Sample Message" + correlationId);
con.registerListener(outboundGateway);
con.send(msg);
// DefaultCachingClientConnectionFactory is the subclass of CachingClientConnectionFactory.
When I send multiple messages, every time I get the same correlation printed in the "onMessage" method.
I read here that Outbound Gateway will correlate messages. Please help me. Maybe I'm doing something wrong.
Thanks
Unless you include correlation data in the message you can't correlate a response to a request.
The gateway achieves this by only allowing one outstanding request on a socket at a time; hence the reply has to be for the request. This is not very useful at high volume with a shared connection; hence the caching client cf was introduced. The gateway keeps a map of outstanding requests based on the connection id.
The gateway, in conjunction with the caching client connection factory should do what you need. However, overriding onMessage is not a good idea, because that's where the reply correlation is done.

Resources