Self-contained win-x64 executable AggregateException: Connection actively refused - windows

I am trying to publish a self-contained executable for Windows. When I try to run the executable via a privileged powershell (or cmd) window, I get the following error:
Unhandled exception. System.AggregateException: One or more errors occurred. (No connection could be made because the target machine actively refused it.)
---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it.
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
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.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
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)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at myProgram.Client.postClaim(Claim Claim, Byte[]& var1, Byte[]& var2, Byte[]& var3)
at myProgram.Program.Main(String[] args)
If it's relevant, on that line, I am connecting to a tomcat-hosted server on another machine.
What is strange, is that when I publish a non-standalone app, I don't get the error. The application runs successfully to completion. I also don't get the error when I run the program in debug mode from within visual studio. Additionally, I've built a self-contained executable for linux-x64, and that was able to run successfully from a linux machine.
I've tried disabling Windows Defender firewall, and similar programs. However, since the program runs fine in those other cases, I'm thinking it's not a firewall issue.
Is there a problem with self-contained executables? Is there something I'm missing before running the self-contained executable on windows? I'm at a loss on how to solve this issue.

Related

Quartz.Net failed on server

I have quartz jobs configured in .Net6 web application. Jobs runs correctly on local computer but site crashes when deployed to server.
both local and server computers have runtime 6.0.10 installed.
I see below error in logs.
System.ArgumentException: cronExpression cannot be null
at Quartz.CronExpression..ctor(String cronExpression)
at Quartz.CronExpression.ValidateExpression(String cronExpression)
at Quartz.CronScheduleBuilder.CronSchedule(String cronExpression)
at Quartz.TriggerExtensions.WithCronSchedule(ITriggerConfigurator triggerBuilder, String cronExpression, Action`1 action)
at Pcc.Preferences.App.Startup.<ConfigureQuartz>b__16_4(ITriggerConfigurator trigger) in /home/vsts/work/1/s/Source/v2/Application/Startup.cs:line 455
at Quartz.ServiceCollectionExtensions.ScheduleJob[T](IServiceCollectionQuartzConfigurator options, Action`1 trigger, Action`1 job)
at Pcc.Preferences.App.Startup.<ConfigureQuartz>b__16_1(IServiceCollectionQuartzConfigurator quartz) in /home/vsts/work/1/s/Source/v2/Application/Startup.cs:line 454
at Quartz.ServiceCollectionExtensions.AddQuartz(IServiceCollection services, NameValueCollection properties, Action`1 configure)
at Quartz.ServiceCollectionExtensions.AddQuartz(IServiceCollection services, Action`1 configure)
Answered here. Sad to see such cross-posting.

Connection refused error between containers when running a simple project with docker compose in visual studio 2019

I am following this tutorial step by step exactly. Very simple one having .net core frontend and backend(webapi) projects.
But the communication between the frontend and the api does not happen. I always get
An unhandled exception occurred while processing the request.
SocketException: Connection refused
System.Net.Http.ConnectHelper.ConnectAsync(string host, int port, CancellationToken
cancellationToken)
HttpRequestException: Connection refused
System.Net.Http.ConnectHelper.ConnectAsync(string host, int port, CancellationToken
cancellationToken)
Looks like I am missing something trivial here. But no matter what I tweak, I get the same communication exception. Driving me nuts now.
I have uploaded the full solution to github here, in case if you want to take a look.
Its a 3.1 project and ensured as closed to the tutorial as possible. Even added a bridge network to the compose file after looking at some posts.
Here are some screen shots.
Finally here is the exception message.
UPDATE
So based on the suggestion of Exploding Kitten in the comment, I had removed the call to
// app.UseHttpsRedirection();
in startup.cs of the Api project and things started working fine.
Or we can have a conditional as follows.
if (Configuration["DOTNET_RUNNING_IN_CONTAINER"] != "true")
app.UseHttpsRedirection();
We can detect if an app is running in the container using the env var DOTNET_RUNNING_IN_CONTAINER. Take a look at this.

Xamarin iOS won't connect to Rest API from a Simulator

I have a Xamarin iOS app that connects to an API (written by me). Sometimes I suffer from a problem where the Simulators (running on Windows 10) will not connect to the API. Whereas the same code runs fine on an iPhone connected to the MAC on my network.
It throws the following exception:
{System.Net.Http.HttpRequestException: An SSL error has occurred and a secure connection to the server cannot be made.
---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1200
"An SSL error has occurred and a secure connection to the server cannot be made."
UserInfo={NSErrorFailingURLStringKey=https://api.staging.MyApp.com/api/v1/LogOn/,
NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,
_kCFStreamErrorDomainKey=3,
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <61E93B00-972D-4DF1-BA39-0141116988C2>.<1>,
_NSURLErrorRelatedURLSessionTaskErrorKey=(\n "LocalDataTask <61E93B00-972D-4DF1-BA39-0141116988C2>.<1>"\n),
NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,
NSErrorFailingURLKey=https://api.staging.MyApp.com/api/v1/LogOn/,
NSUnderlyingError=0x600001cac840 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0,
_kCFNetworkCFStreamSSLErrorOriginalValue=-9816,
_kCFStreamErrorDomainKey=3,
_kCFStreamErrorCodeKey=-9816}},
_kCFStreamErrorCodeKey=-9816}\n
--- End of inner exception stack trace ---\n
at System.Net.Http.NSUrlSessionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x001d4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:523 \n
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask,
System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts,
System.Boolean disposeCts) [0x0017e] in
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506 \n at MyApp.Mobile.Api.LogOnUser (MyApp.Mobile.VM.LogOnVM vm) [0x000b2] in D:\Projects\MyAppCore\MyApp.Mobile\MyApp.Mobile\Api.cs:114 }
Just to repeat, the VERY SAME code is running on the physical iphone (and android emulators/phone) perfectly.
Any ideas as to why are appreciated. Thanks.
Following the information Jason provided, I decided to reboot the MAC. And voila! All working again.
I think it may be caused by me starting up 'ExpressVPN' on the PC. I noticed when that is running, the Android won't connect either. However, when I stop it, the Android is OK. But I suspect the Apple never works again until the MAC is rebooted. Not 100% sure that is the reason, but I hope this will help others.
OK - It was NOT the VPN. But rebooting the MAC seems to fix the issue every time.

Azure Function v2 Web Deploy experienced a connection problem with the server and had to terminate the connection

When trying to publish a V2 function from Visual Studio I'm getting a publish error:
Publish has encountered an error.
Publishing failed.
The messages from the Output windows are:
Web deployment task failed. (Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists.
Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists.
Unexpected end of file has occurred. The following elements are not closed: results. Line 1, position 550.
The contents of the diagnostics log are:
06/05/2019 11:32:37
System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.Model.DefaultPublishSteps.d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.d__183.MoveNext()
---> (Inner Exception #0) System.Exception: Publishing failed.<---
I have created a new HTTP function, tested it locally and the attempted to publish it.
Anyone know how to fix this?
Found the fix to this problem by walking through the quick start guide (again):
Publish the Project to Azure
You need to select the option for "Run from package file (recommended)".

Azure AppFabric caching. ErrorCode<ERRCA0017>:SubStatus<ES0006>

there is a very strange thing going on
i have a web site made in MVC 3 deployed in an Azure WebRole
it was running fine and originally was made in VS2010
now i use VS2012
i decided to make some minor changes and it appeared to be working but keeps break down at random intervals
this is what is happening
after random intervals i get this error ErrorCode<ERRCA0017>:SubStatus<ES0006>
after 2-3 minutes of getting this error sites appears to be working fine
i havent changed anything from the previous version of the site related to caching
this error does nt happens when i test it in staging or in local environment
no where in my code im accessing this cache programmatically
i have copy-pasted entire configuration as it is from the azure portal and i know it it correct because these are the same configuration settings that were working before
i just using Azure AppFabric Caching because i need to save sessions some where. so the only place it is ever mentioned is in my websites web config and as i have told all the configuration can be assumed to be correct.
this is the stacktrace if this can be of some help
[DataCacheException: ErrorCode<ERRCA0017>:SubStatus<ES0006>:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody) +616
Microsoft.ApplicationServer.Caching.DataCache.ExecuteAPI(RequestBody reqMsg, IMonitoringListener listener) +29
Microsoft.ApplicationServer.Caching.DataCache.InternalGetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle, String region, Boolean lockKey, IMonitoringListener listener) +227
Microsoft.ApplicationServer.Caching.<>c__DisplayClass78.<GetAndLock>b__77() +103
Microsoft.ApplicationServer.Caching.DataCache.GetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle) +258
Microsoft.Web.DistributedCache.<>c__DisplayClass31`1.<PerformCacheOperation>b__30() +19
Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action) +208
Microsoft.Web.DistributedCache.DataCacheForwarderBase.GetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle) +190
Microsoft.Web.DistributedCache.BlobBasedSessionStoreProvider.GetItem(HttpContextBase context, String id, Boolean acquireWriteLock, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +593
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +125
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +178
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1076
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +115
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
UPDATE:-
suddenly i discovered a new error which seems to me as one of the inner errors many sites talk about
error description
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 [IP-Address]:[PORT]
and this is the new stack trace
[SocketException (0x274c): 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 [IP-ADDRESS]:[PORT]]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +305
System.Net.Sockets.Socket.Connect(EndPoint remoteEP) +162
System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout) +774
[EndpointNotFoundException: Could not connect to [SOCKET-ENDPOINT]. The connection attempt lasted for a time span of 00:00:21.0308462. TCP error code 10060: 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 111.221.89.111:22233. ]
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase) +518
System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData) +401
Microsoft.ApplicationServer.Caching.OpenDelegate.EndInvoke(IAsyncResult result) +0
Microsoft.ApplicationServer.Caching.ChannelContainer.Opened(IAsyncResult ar) +122
There was an interesting blog post about this error over a year ago: Azure AppFabric Caching - ErrorCode:SubStatus : What to do?.
Before intializing the DataCacheFactory modify the
DataCacheFactoryConfiguration.ChannelOpenTimeout of the
dataCacheFactoryConfiguration instance that you are using to a larger
value of 2 minutes. (can't use configuration to set the value, since
20 seconds in the allowed limit) . Also, this recommendation is only
for debugging purposes and ideally should not be needed in production
environments. This lets the underlying layer to respond back with the actual error
that occurred. Now, if you check the inner exception, you should see
what caused the request to fail.
Please follow these steps to find the inner exception which will explain why the request fails.
Note: If this is caused by a transient fault, you should consider using the Transient Fault Handling Application Block (which also supports AppFabric Cache) in order to implement a retry policy.

Resources