Xamarin形式-Can';t使用url https连接到信号器(不适用于iOS,但适用于Android) 试试看 { System.Net.ServicePointManager.ServerCertificateValidationCallback=委托{return true;}; _连接=新的HubConnectionBuilder() .WithUrl(“https://xxx.xxx.xxx.xxx:xxx") .Build(); _连接。On(“,OnSend); wait_connection.StartAsync(); } 捕获(例外情况除外) { 等待显示警报(“,例如消息“OK”); } 专用void OnSend(字符串名称、字符串消息) { //日志(颜色.黑色,名称+”:“+消息); }

Xamarin形式-Can';t使用url https连接到信号器(不适用于iOS,但适用于Android) 试试看 { System.Net.ServicePointManager.ServerCertificateValidationCallback=委托{return true;}; _连接=新的HubConnectionBuilder() .WithUrl(“https://xxx.xxx.xxx.xxx:xxx") .Build(); _连接。On(“,OnSend); wait_connection.StartAsync(); } 捕获(例外情况除外) { 等待显示警报(“,例如消息“OK”); } 专用void OnSend(字符串名称、字符串消息) { //日志(颜色.黑色,名称+”:“+消息); },ios,xamarin,xamarin.forms,signalr,Ios,Xamarin,Xamarin.forms,Signalr,我正在使用Visual Studio 2017版本15.8.0预览版5.0对mac mini版本10.13.3 并在iphonesimulator上运行 获取了以下异常: try { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; _connection = new HubConnecti

我正在使用Visual Studio 2017版本15.8.0预览版5.0对mac mini版本10.13.3 并在iphonesimulator上运行

获取了以下异常:

 try
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            _connection = new HubConnectionBuilder()
                .WithUrl("https://xxx.xxx.xxx.xxx:xxx")
                .Build();
            _connection.On<string, string>("", OnSend);
            await _connection.StartAsync();
        }
        catch (Exception ex)
        {
            await DisplayAlert("", ex.Message, "OK");
        }
private void OnSend(string name, string message)
    {
        //Log(Color.Black, name + ": " + message);
    }
System.Net.Http.HttpRequestException:发送请求时出错-->System.Net.WebException:操作已超时。
位于/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:952中的System.Net.HttpWebRequest+d_u241`1[T].MoveNext()[0x000b5]
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1180中的System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asynchresult)[0x00018]
在System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic(System.IAsyncResult iar,System.Func`2[T,TResult]endFunction,System.Action`1[T]endAction,System.Threading.Tasks.Task`1[TResult]promise,System.Boolean requiresSynchronization)[0x0000f]在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs:550中
---来自引发异常的上一个位置的堆栈结束跟踪---
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:187中的System.Runtime.CompilerServices.taskwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x00037]
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:156中的System.Runtime.CompilerServices.taskwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:128中的System.Runtime.CompilerServices.taskauer.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/System/Runtime/CompilerServices/TaskAwaiter.cs:535中的System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult()[0x00000]
位于/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Net.Http/System.Net.Http/HttpClientHandler.cs:402中的System.Net.Http.HttpClientHandler+d_u64.MoveNext()[0x003d3]
---内部异常堆栈跟踪的结束---

发布您的WebHost.CreateDefaultBuilder代码。防火墙是否阻止访问?公共静态IWebHostBuilder CreateWebHostBuilder(字符串[]args)=>WebHost.CreateDefaultBuilder(args.UseStartup();服务器客户端和mac已关闭防火墙您在哪里配置URL?如何运行服务器?你用吗?谢谢。我通过在另一台服务器上运行服务器解决了这个问题
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: The operation has timed out.
  at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__241`1[T].MoveNext () [0x000b5] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:952 
--- End of stack trace from previous location where exception was thrown ---
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1180 
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs:550 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.11/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
  at System.Net.Http.HttpClientHandler+<SendAsync>d__64.MoveNext () [0x003d3] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:402 
   --- End of inner exception stack trace ---