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.
Related
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.
I am trying to use Xamarin.UITest locally, but I am getting a httprequest exception, saying that the connection has been refused
I am using xcode 9.3, vs 7.4.2 and an iphone 10.3 iphone x sim
Xamarin.Ui.Test 2.2.4, Xamarin.Testcloud.Agent 0.21.4, NUnit 3.10.1
When Trying to run my test I get the following Exception:
Xamarin.UITest.XDB.Exceptions.DeviceAgentException : DeviceAgent start session failed: An error occurred while sending the request
----> System.Net.Http.HttpRequestException : An error occurred while sending the request
----> System.Net.WebException : Error: ConnectFailure (Connection refused)
----> System.Net.Sockets.SocketException : Connection refused
I got it working by restarting the mac and putting the Calabash.Start() call right on top of the FinishedLaunching method. If one or both saved the day, I don't know.
Although it's an old post, others might look for it.
That error means that the simulator doesn't start quickly enough for the next test.
There is an active bug opened here https://github.com/Microsoft/appcenter/issues/340#
What you can do is either set the variable to 0 and manually restart the emulator to pick the new code.
Also, be sure that NUnit package version is max 2.6.x. Newest 3.0 is not supported by Xamarin.UITest
I'm trying to publish my Unity multiplayer game to Mac App Store, but by some reason in production the socket fails to connect to server, throwing the following exception:
"Access denied System.Net.Sockets.Socket.Bind".
I have "com.apple.security.network.client" and "com.apple.security.app-sandbox" entitlement, but it does not work. HTTP requests work OK though.
If I test the app in debug build - it works..what could be blocking it ? The port I'm using is 16005
This is the client connection code:
var tcpClient = new TcpClient();
tcpClient.Connect(Host, Port);
networkStream = tcpClient.GetStream();
listenThread = new Thread(ListenToServer);
listenThread.Start();
Any ideas ?
I Solved the problem.
It turns out I had to add the server entitlement too.
(Although I'm not starting any server nor listening for incoming connections).
So adding "com.apple.security.network.server" entitlement solved the problem
Unable to connect to the feedback.sandbox.push.apple.com with port number 2196.
Opened the ports (5223, 2915, 2916, 443) in windows firewall with TCP/SSL.
Tried connecting via telnet too, but did not help.
Getting the below exception
Service Exception: PushSharp.Apple.ApplePushService -> System.Net.Sockets.Socket
Exception (0x80004005): A connection attempt failed because the connected party
did not properly respond after a period of`enter code here` time, or established connection faile
d because connected host has failed to respond 17.172.232.45:2196
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, Can
cellationToken cancelToken) in d:\Sample Apps\Push Notification\PushSharp-master
\PushSharp-master\PushSharp.Apple\FeedbackService.cs:line 60
at PushSharp.Apple.ApplePushService.<>c__DisplayClass4.<.ctor>b__1(Object sta
te) in d:\Sample Apps\Push Notification\PushSharp-master\PushSharp-master\PushSh
arp.Apple\ApplePushService.cs:line 51
Failure: PushSharp.Apple.ApplePushService -> The maximum number of Send attempts
to send the notification was reached! -> {"aps":{"alert":"Hello World!","badge"
:7,"sound":"sound.caf"}}
Also, this does not need certificate to connect to sandbox, so why this exception?
You do need a development certificate from the Apple Developer portal to connect to sandbox. But I don't know if you need to use it to connect to feedback.sandbox.apple.
I can't seem to find a straight answer on this whether feedback services still works. I think APNS Feedback services are now deprecated. This could be why you're getting this error.
Does APNS Feedback service no longer exist as per new APIs?
APNS Feedback Service - is it still alive?
I have developed a webservice using WCF and secured it using NTLM over SSL. I am able to connect successfully using from a visual Studio 2008 form or Web Project. The problem I am having is when creating a smart device project and deploying it on the device.
when I call the service, from client side I get the error: Web Exception
on the server site, when i check the Event Log I get the following Error:
**Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/7491627
Exception: System.Web.HttpException (0x80004005): There was no channel actively listening at 'https://mymachine:9011/FrontEndWS/MeterReadingService.svc/$metadata'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening. --->
System.ServiceModel.EndpointNotFoundException: There was no channel actively listening at 'https://mymachine:9011/FrontEndWS/MeterReadingService.svc/$metadata'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)**
Process Name: w3wp
Process ID: 2828
Cannot figure out why this is happening from mobile devices but works fine from a PC.