EasyNetQ not reconnecting after RabbitMQ server was unreachable - rabbitmq

I am trying some edge cases in my software. So I have created a very simple test environment:
RabbitMQ server running on CentOS 7
Message consumer written against .NETCore 2.1 in C# running under CentOS 7
Message sender written against .NETCore 2.1 in C# running under CentOS 7
I send a simple text message every 5 seconds. The sender and receiver run on the same UNIX box, while the RabbitMQ server runs on a different machine in the network.
So far so good. Now I stop my RabbitMQ server with systemctl stop rabbitmq-server.
I get errors on the sender and the receiver which was expected.
I restart the RabbitMQ server using systemctl start rabbitmq-server.
And now the fun starts! The sender can recover and continues to send messages but the consumer CANNOT recover and does not receive messages. They are accumulated on the RabbitMQ server!
Here are my log entries from the sender (which works as expected):
2019-01-22 21:18:25.628 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 10] Failed to connect to broker infraserver-tbws2, port 5672, vhost testvh
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Connection failed) ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.16.63.239:5672
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__272_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String host, Int32 port)
at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, Int32 millisecondsTimeout)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout, AddressFamily family)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
at EasyNetQ.ConnectionFactoryWrapper.CreateConnection()
at EasyNetQ.PersistentConnection.TryToConnect()
2019-01-22 21:18:25.632 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 10] Failed to connect to any Broker. Retrying in 00:00:05
2019-01-22 21:18:35.444 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 7.' | Num: 7 | Guid: 5345c7e4-61e6-4c79-8179-d4bef7864420'.
2019-01-22 21:18:40.452 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 8.' | Num: 8 | Guid: 3cd8635c-cdfa-45f3-8495-2acb0713d47b'.
2019-01-22 21:18:45.457 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 9.' | Num: 9 | Guid: 099462b8-cd66-40b9-ac10-89c3246819ec'.
2019-01-22 21:18:50.470 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 10.' | Num: 10 | Guid: c25139b2-8e45-4771-9544-830014382e0c'.
2019-01-22 21:18:55.515 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 11.' | Num: 11 | Guid: 90049d91-3805-4aaa-ac18-b61c09164afd'.
2019-01-22 21:19:00.526 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 12.' | Num: 12 | Guid: 108ff318-6a34-4e64-94bd-dafa67aa6717'.
This shows the last error message and then one can see that EasyNetQ recovered and can deliver messages again.
The message consumer does NOT work! Here my log entries:
2019-01-22 21:18:25.623 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 12] Failed to connect to broker infraserver-tbws2, port 5672, vhost testvh
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Connection failed) ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.16.63.239:5672
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__272_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String host, Int32 port)
at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, Int32 millisecondsTimeout)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout, AddressFamily family)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
at EasyNetQ.ConnectionFactoryWrapper.CreateConnection()
at EasyNetQ.PersistentConnection.TryToConnect()
2019-01-22 21:18:25.625 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 12] Failed to connect to any Broker. Retrying in 00:00:05
Here it sits and waits forever! Looks like the thing is deadlocked in a way while the messages are accumulating on the RabbitMQ server:
When I stop my consumer application and restart it, the messages are picked up.
I connect in both applications (sender and consumer) with the following code:
private static IBus SetupRabbitMqConnection(string rabbitServer, string rabbitVHost, ushort rabbitPort, string rabbitUser, string rabbitPwd)
{
Log.Logger.Debug($"Creating a connection to RabbitMQ server '{rabbitServer}' on port {rabbitPort.ToString()} " +
$"using the EasyNetQ library....");
try
{
var connStr = $"host={rabbitServer}:{rabbitPort.ToString()};virtualHost={rabbitVHost};username={rabbitUser};" +
$"password={rabbitPwd};publisherConfirms=true;timeout=30;prefetchcount=1;requestedHeartbeat=30";
var msgBus = RabbitHutch.CreateBus(connStr, x => { });
if (!msgBus.IsConnected)
{
var errMsg = $"Currently not connected to RabbitMQ server '{rabbitServer}'.";
Log.Logger.Error(errMsg);
}
Log.Logger.Debug("Successfully connected to RabbitMQ server.");
return msgBus;
}
catch (Exception ex)
{
Log.Logger.Error($"Error to establish a connection to RabbitMQ server '{rabbitServer}'. Error: {ex}");
throw;
}
}
The consumer program registers the listeners as follows:
var msgBus = SetupRabbitMqConnection(rabbitServer, vhost, rabbitPort, rabbitUser, rabbitPwd);
RegisterMsgSubscriptions(msgBus);
private static void RegisterMsgSubscriptions(IBus msgBus)
{
Log.Logger.Debug("Starting to register RabbitMQ message subscriptions...");
try
{
#region Queue declarations
var advancedBus = msgBus.Advanced;
var testQueueOne = new EasyNetQ.Topology.Queue(TestQueueOneName, true);
Log.Logger.Debug("Finished declaring queues.");
#endregion
#region Message Queue Handler registrations
advancedBus.Consume(testQueueOne, registration => registration
.Add<RabbitMessage<TestTextMessageDto>>(MessageProcessor.ProcessRabbitTestMessage));
Log.Logger.Debug("Finished registration of message handlers for several queues.");
#endregion
}
catch (Exception ex)
{
Log.Logger.Error($"Error registering message handler. Error: {ex}");
}
}
Any idea what might go wrong here?? In production we have more than 100 servers consuming messages. These servers are on premise spread all over the country. The RabbitMQ server is in the data center. So the consuming servers MUST recover if the connection gets lost, otherwise this is not usable!

Just add subscription logic on connected event (It will be fired on every broker connected event).
advancedBus.Connected += (sender, args) => {
// subscribe logic
};
Of course You should handle not to call subscribe logice twice on any connect etc.

Related

RabbitMQ .NET Client library Code 541 Unexpected Exception during load testing

Our application uses RabbitMQ .NET client to publish and consume messages and during loading testing we are getting the following issue in one of our application where the connection to RabbitMQ gets dropped. The following is the stacktrace of the application,
Message: Already closed: The AMQP operation was interrupted: AMQP
close-reason, initiated by Library, code=541, text='Unexpected
Exception', classId=0, methodId=0, cause=System.IO.IOException: Unable
to read data from the transport connection: An existing connection was
forcibly closed by the remote host.. --->
System.Net.Sockets.SocketException (10054): An existing connection was
forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BufferedStream.ReadByteSlow()
at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(Stream reader, Byte[] frameHeaderBuffer)
at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration()
at RabbitMQ.Client.Framing.Impl.Connection.MainLoop() Type: RabbitMQ.Client.Exceptions.AlreadyClosedException ShutdownReason:
AMQP close-reason, initiated by Library, code=541, text='Unexpected
Exception', classId=0, methodId=0, cause=System.IO.IOException: Unable
to read data from the transport connection: An existing connection was
forcibly closed by the remote host.. --->
System.Net.Sockets.SocketException (10054): An existing connection was
forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BufferedStream.ReadByteSlow()
at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(Stream reader, Byte[] frameHeaderBuffer)
at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration()
at RabbitMQ.Client.Framing.Impl.Connection.MainLoop() HResult: -2146233088 Source: RabbitMQ.Client Stack Trace: at RabbitMQ.Client.Framing.Impl.Connection.EnsureIsOpen()
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.EnsureIsOpen()
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.CreateModel()
at Playtech.Neon.MQ.Client.RabbitMQ.RabbitMQClient.<>c__DisplayClass14_0.b__2()
at Polly.Policy.<>c__DisplayClass114_01.<Execute>b__0(Context ctx, CancellationToken ct) at Polly.Retry.RetryEngine.Implementation[TResult](Func3 action, Context context, CancellationToken cancellationToken,
ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates1 shouldRetryResultPredicates, Action4 onRetry, Int32
permittedRetryCount, IEnumerable1 sleepDurationsEnumerable, Func4
sleepDurationProvider)
Any idea why this happens?

WCF call error: A connection attempt failed because the connected party did not properly respond after a period of time

I've written a WCF service hosted on server 1. I can call it successfully from my local pc, but when I try to call the same function from server 2. it shows below error:
One or more errors occurred. (A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond.
my code is:
var client = new Sepidar_WcfService.SepidarClient();
Task<Sepidar_WcfService.ISepidarServiceOutput> tStocks = client.GetStocksAsync("1", "1");
the stack trace is:
System.AggregateException: One or more errors occurred. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) ---> System.ServiceModel.CommunicationException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask) at System.Threading.Tasks.ValueTask1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at System.ServiceModel.Channels.HttpChannelFactory1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.SendRequestAsync(Message message, TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at Nop.Services.Catalog.UpdateWarehouses.Execute() at Nop.Services.Tasks.Task.ExecuteTask() at Nop.Core.Caching.MemoryCacheManager.PerformActionWithLock(String key, TimeSpan expirationTime, Action action) in C:\Business\Projects\nopCommerce_4.10_Source\Libraries\Nop.Core\Caching\MemoryCacheManager.cs:line 205 at Nop.Services.Tasks.Task.Execute(Boolean throwException, Boolean ensureRunOncePerPeriod) ---> (Inner Exception #0) System.ServiceModel.CommunicationException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.SendRequestAsync(Message message, TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult)<---
any help would be appriciated!
I found the problem, The problem is, I try to call the WCF service with http, while service client has https protocol. Thus the issue is related to "same origin policy" concept.

RavenDb Let's encrypt certificate setup failed on Azure

I have installed RavenDb on Ubuntu system (on Azure cloud) using Docker and trying to use LetsEncrypt wizard to generate the certificate.
My ravendb installation is successful and this is the port setup
root#XXXX:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64ee58cab746 ravendb/ravendb "/bin/sh -c /opt/Rav…" 6 hours ago Up 6 hours (healthy) 161/tcp, 0.0.0.0:9002->8080/tcp, 0.0.0.0:48888->38888/tcp ravendb
47b715b56482 bitnami/neo4j:latest "/app-entrypoint.sh …" 43 hours ago Up 15 hours 0.0.0.0:7473-7474->7473-7474/tcp, 0.0.0.0:7687->7687/tcp, 8756/tcp neo4j
Based on the configuration I tried to setup ravendb with following configuration,
Node Tag A
HTTPS Port 9002
TCP Port 48888
IP Address / Hostname 0.0.0.0
External IP Address X.X.X.X
External HTTPS Port 9002
External TCP Port 48888
;but it gives me following error
PS: To debug this issue, I just opened all the ports inbound and outbound on azure VM
This seems the main culprit in code below:
The SSL connection could not be established, see inner exception. ---> System.IO.IOException: The handshake failed due to an unexpected packet format.
Setting up RavenDB in Let's Encrypt security mode failed.
System.InvalidOperationException: Setting up RavenDB in Let's Encrypt security mode failed. ---> System.InvalidOperationException: Validation failed. ---> System.InvalidOperationException: Failed to simulate running the server with the supplied settings using: https://a.educosys-db.ravendb.community:9002 ---> System.InvalidOperationException: Client failed to contact webhost listening to 'https://a.educosys-db.ravendb.community:9002'.
Are you blocked by a firewall? Make sure the port is open.
Settings file:/opt/RavenDB/Server/settings.json.
IP addresses: 0.0.0.0:9002.
Response: .
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.IO.IOException: The handshake failed due to an unexpected packet format.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Raven.Server.Commercial.SetupManager.SimulateRunningServer(X509Certificate2 serverCertificate, String serverUrl, String nodeTag, IPEndPoint[] addresses, Int32 port, String settingsPath, SetupMode setupMode, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 1966
--- End of inner exception stack trace ---
at Raven.Server.Commercial.SetupManager.SimulateRunningServer(X509Certificate2 serverCertificate, String serverUrl, String nodeTag, IPEndPoint[] addresses, Int32 port, String settingsPath, SetupMode setupMode, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 1983
at Raven.Server.Commercial.SetupManager.SimulateRunningServer(X509Certificate2 serverCertificate, String serverUrl, String nodeTag, IPEndPoint[] addresses, Int32 port, String settingsPath, SetupMode setupMode, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 1995
at Raven.Server.Commercial.SetupManager.ValidateServerCanRunWithSuppliedSettings(SetupInfo setupInfo, ServerStore serverStore, SetupMode setupMode, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 980
--- End of inner exception stack trace ---
at Raven.Server.Commercial.SetupManager.ValidateServerCanRunWithSuppliedSettings(SetupInfo setupInfo, ServerStore serverStore, SetupMode setupMode, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 984
at Raven.Server.Commercial.SetupManager.SetupLetsEncryptTask(Action`1 onProgress, SetupInfo setupInfo, ServerStore serverStore, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 475
--- End of inner exception stack trace ---
at Raven.Server.Commercial.SetupManager.SetupLetsEncryptTask(Action`1 onProgress, SetupInfo setupInfo, ServerStore serverStore, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 479
--- End of inner exception stack trace ---
at Raven.Server.Commercial.SetupManager.LogErrorAndThrow(Action`1 onProgress, SetupProgressAndResult progress, String msg, Exception e) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 649
at Raven.Server.Commercial.SetupManager.SetupLetsEncryptTask(Action`1 onProgress, SetupInfo setupInfo, ServerStore serverStore, CancellationToken token) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Commercial\SetupManager.cs:line 506
at Raven.Server.Web.System.SetupHandler.SetupLetsEncrypt() in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Web\System\SetupHandler.cs:line 650
at Raven.Server.Routing.RequestRouter.HandlePath(RequestHandlerContext reqCtx) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\Routing\RequestRouter.cs:line 189
at Raven.Server.RavenServerStartup.RequestHandler(HttpContext context) in C:\Builds\RavenDB-Stable-4.2\42034\src\Raven.Server\RavenServerStartup.cs:line 173

Kentico SMTP: use TLS instead of SSL

I have got configuration settings from my provider how to connect to POP3/SMTP server. It works perfectly in Outlook, but it doesn't work with Kentico (Azure hosted).
Note: In case of Gmail SMTP settings (with SSL enabled) Kentico works perfectly.
In Kentico I use the following configuration (below) but I don't have the possiblity to adjust the protocol (TLS is important in my case) and the port number (587).
smtp server - email.active24.com
use ssl - checked
login - XXX#YYY.ZZZ
password - NNN
The error (see below) contains two messages:
Message: Unable to connect to the remote server
Message: No connection could be made because the target machine actively refused it 81.95.97.101:25
Message: Failure sending mail.
Exception type: System.Net.Mail.SmtpException
Stack trace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at CMS.EmailEngine.EmailProvider.SendEmailInternal(String siteName, MailMessage message, SMTPServerInfo smtpServer)
at CMS.EmailEngine.EmailSender.SendTestEmail(String siteName, EmailMessage message, SMTPServerInfo smtpServer)
at CMSModules_System_System_Email.SendEmail() in C:\Projects\Kentico\_install\CMS\CMSModules\System\System_Email.aspx.cs:line 122
at CMSModules_System_System_Email.btnSend_Click(Object sender, EventArgs e) in C:\Projects\Kentico\_install\CMS\CMSModules\System\System_Email.aspx.cs:line 78
Message: Unable to connect to the remote server
Exception type: System.Net.WebException
Stack trace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
Message: No connection could be made because the target machine actively refused it 81.95.97.101:25
Exception type: System.Net.Sockets.SocketException
Stack trace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
I need to set the following configuration:
Please suggest me how to do that.
The right answer is to use the smtp server name together with the port number like:
email.active24.com:587

NServiceBus Could not load file or assembly

I am getting the below error when i call "NServiceBus.Host.exe". The issue appears to be itextsharp.dll. I've read that i can use
"Configure.With(AllAssemblies.Except("itextsharp.dll"))... // rest of your config"
But i'm using the following sample and not sure where to add this property.
http://docs.particular.net/samples/web/asp-mvc-application/
#
Unhandled Exception: Magnum.StateMachine.StateMachineException: Exception occurr
ed in Topshelf.Internal.ServiceController1[[NServiceBus.Host.Internal.GenericHo
st, NServiceBus.Host, Version=2.6.0.1504, Culture=neutral, PublicKeyToken=9fc386
479f8a226c]] during state Initial while handling OnStart ---> System.Exception:
Exception when starting endpoint, error has been logged. Reason: Could not load
file or assembly 'file:///D:\dev\MYSITE\MYSITE.EStore\EStore.Server\bin\Debug\itexts
harp.dll' or one of its dependencies. Operation is not supported. (Exception fro
m HRESULT: 0x80131515)
at NServiceBus.Host.Internal.GenericHost.Start() in d:\BuildAgent-02\work\20b
5f701adefe8f8\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 90
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
--- End of inner exception stack trace ---
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary1.HandleException(T stateMac
hine, Event event, Object parameter, Exception exception) in :line 0
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
at Magnum.StateMachine.State1.RaiseEvent(T instance, BasicEvent1 eevent, Ob
ject value) in :line 0
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised) in :line 0
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(
IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInCont
ext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMes
sage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start() in d:\dev\open-source\topshel
f\src\Topshelf\Internal\ServiceCoordinator.cs:line 54
at Topshelf.Internal.Hosts.ConsoleHost.Run() in d:\dev\open-source\topshelf\s
rc\Topshelf\Internal\Hosts\ConsoleHost.cs:line 53
at NServiceBus.Host.Program.Main(String[] args) in d:\BuildAgent-02\work\20b5
f701adefe8f8\src\host\NServiceBus.Host\Program.cs:line 103
When NserviceBus host starts it tries to retrieve all types from assemblies you specify.
In the sample you provide it uses NServiceBus.Configure.WithWeb() method.
This is the same as to call NServiceBus.Configure.With(AppDomain.CurrentDomain.DynamicDirectory)
You get the excpetion because "itextsharp.dll" cannot be loaded to AppDomain (this is done by calling Assembly.LoadFrom(file.FullName) method).
To fix the issue, you may manually specify assemblies you need to scan by using one of NServiceBus.Configure.With() overloads.