Hi,
I'm trying to get a Signalr Client Hubconnection working on Xamarin but only receiving timeouts.
The Hubconnection works fine on the web application:
Information: Normalizing '/signalr-document-conversion' to 'https://localhost:44302/signalr-document-conversion'. WebSocket connected to wss://localhost:44302/signalr-document-conversion?id=b8_kizi_mCESajbklz7pyQ.
The Xamarin code:
` try { HubConnection = new HubConnectionBuilder() .WithUrl("https://192.168.0.22:44302/signalr-document-conversion" ).ConfigureLogging(logging => { logging.SetMinimumLevel(LogLevel.Debug); logging.AddConsole(); logging.AddDebug(); }) .Build();
HubConnection.On<int, int>("DocumentReordered", (documentId, newOrderIndex) =>
{
Console.WriteLine("TEST");
});
HubConnection.On<int, string, string, string>("DocumentStatusChanged", (documentId, status, fileName, fileTypeImageName) =>
{
Console.WriteLine("TEST");
});
await HubConnection.StartAsync();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
`
The log
` 08-03 12:46:59.476 I/mono-stdout(13938): Starting HubConnection. [40m[37mdbug[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1] Starting HttpConnection. 08-03 12:46:59.481 I/mono-stdout(13938): [40m[37mdbug[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1] 08-03 12:46:59.481 I/mono-stdout(13938): Starting HttpConnection. [0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Debug: Starting HttpConnection. [40m[37mdbug[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] 08-03 12:46:59.493 I/mono-stdout(13938): [40m[37mdbug[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. 08-03 12:46:59.493 I/mono-stdout(13938): Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. [0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Debug: Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. 08-03 12:46:59.537 V/ViewRootImpl(13938): The specified message queue synchronization barrier token has not been posted or has already been removed 08-03 12:46:59.565 D/DecorView(13938): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@5231d85[MainActivity] [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[10] Failed to start connection. Error getting negotiation response from 'https://192.168.0.22:44302/signalr-document-conversion'. System.Net.Http.HttpRequestException: Connection timed out ---> System.Net.Sockets.SocketException: Connection timed out at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x000c8] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:65 --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x00180] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/Sock 08-03 12:47:24.563 I/mono-stdout(13938): [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[10]etsHttpHandler/ConnectHelper.cs:84 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:385 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/w
08-03 12:47:24.563 I/mono-stdout(13938): Failed to start connection. Error getting negotiation response from 'https://192.168.0.22:44302/signalr-document-conversion'.orkspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net
`
The Xamarin app is being run from a phone and the webhost is on a pc. I'm able to connect to all the other services from the phone just fine.
Prerequisites What is your product version? - v10.0.0 What is your product type (Angular or MVC)? - MVC What is product framework type (.net framework or .net core)? - Core
13 Answer(s)
-
0
Hi,
Could you add this Mobile profile to your MVC project's launchSettings https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/Properties/launchSettings.json#L18 and run your project with Mobile profile and try again ?
-
0
Hi,
I'm getting a git 404 error from that link.
-
0
Hi,
Please add your GitHub user on https://aspnetzero.com/LicenseManagement and try again. Thanks,
-
0
Hi,
I tried using the mobile profile on MVC and had no different result.
I am currently running 3 projects, HOST, MVC and DROID. The SignalR connection works fine for MVC to HOST but not DROID to HOST.
-
0
Hi @Astech
Do you have
app.UseHttpsRedirection();
in your Startup.cs ? If so, could you disable it and try again ? -
0
HI @ismcagdas
I have tried disabling that line however when I startup my xamarin app whilst the mvc/host are running I get the following exception regardless of that line of code:
Call timed out: GET https://192.168.0.22:44301/AbpUserConfiguration/GetAll
at Flurl.Http.FlurlRequest.HandleExceptionAsync (Flurl.Http.FlurlCall call, System.Exception ex, System.Threading.CancellationToken token) [0x000e6] in C:\projects\flurl\src\Flurl.Http\FlurlRequest.cs:344 at Flurl.Http.FlurlRequest.SendAsync (System.Net.Http.HttpMethod verb, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken, System.Net.Http.HttpCompletionOption completionOption) [0x00358] in C:\projects\flurl\src\Flurl.Http\FlurlRequest.cs:195 at Flurl.Http.FlurlRequest.SendAsync (System.Net.Http.HttpMethod verb, System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken, System.Net.Http.HttpCompletionOption completionOption) [0x00480] in C:\projects\flurl\src\Flurl.Http\FlurlRequest.cs:201 at Flurl.Http.ResponseExtensions.ReceiveJson[T] (System.Threading.Tasks.Task
1[TResult] response) [0x00024] in C:\projects\flurl\src\Flurl.Http\ResponseExtensions.cs:24 at Congresso.ApiClient.AbpApiClient.ValidateAbpResponse[T] (System.Threading.Tasks.Task
1[TResult] httpResponse, System.Boolean stripAjaxResponseWrapper) [0x000d0] in C:\Repos\Congresso\src\Congresso.Application.Client\ApiClient\AbpApiClient.cs:372My Web.Mvc is running on app url https://localhost:44302 My Web.Host is running https://localhost:44301
-
0
Managed to fix the previous problem and I'm getting the following exception when trying to connect to signalr
The SSL connection could not be established, see inner exception.
at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:165
When trying https://192.168.0.22:44301/signalr-document-conversion
-
0
Hi @Astech
Does that work when you use the http URL (http://192.168.0.22:44301/signalr-document-conversion) ?
-
0
Hi,
No I get the following exception instead:
An error occurred while sending the request.
at System.Net.Http.HttpConnection.SendAsyncCore (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x012d9] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs:743 at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync (System.Net.Http.HttpConnection connection, System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x000e6] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:330 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x00101] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:296 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 at Microsoft.AspNetCore.Http.Connections.Client.Internal.AccessTokenHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ff] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00095] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task
1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x000b3] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:531 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync (System.Uri url, System.Net.Http.HttpClient httpClient, Microsoft.Extensions.Logging.ILogger logger, System.Threading.CancellationToken cancellationToken) [0x00257] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync (System.Uri uri, System.Threading.CancellationToken cancellationToken) [0x00080] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00180] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00127] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00091] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) [0x00114] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync (System.Net.EndPoint endPoint, System.Threading.CancellationToken cancellationToken) [0x001bf] in <559e9e9efbf743acb6b2cd8b35a77f26>:0 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x000a5] in <9b5c746cf3e24d3daddf4fedfbec16df>:0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner (System.Threading.CancellationToken cancellationToken) [0x001a4] in <9b5c746cf3e24d3daddf4fedfbec16df>:0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <9b5c746cf3e24d3daddf4fedfbec16df>:0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) [0x00091] in <9b5c746cf3e24d3daddf4fedfbec16df>:0 at Congresso.App.OnStart () [0x001c0] in C:\Repos\Congresso\src\Congresso.Mobile.Shared\App.xaml.cs:141 -
0
Hi @Astech
Everything seems normal in your case. As a last request, could you share your signalr-document-conversion definition on server side ?
I think your app works wihtout the signalR connection, right ? I mean the device can connect to server side api ?
Thanks,
-
0
Hi,
Yes the app works fine connecting to the api.
These are the snippets, let me know if this is what you expected to see:
` public class DocumentHub : Hub { }
app.UseEndpoints(endpoints => { endpoints.MapHub<AbpCommonHub>("/signalr"); endpoints.MapHub<DocumentHub>("/signalr-document-conversion"); endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); } }); await _documentHub.Clients.All.SendAsync("DocumentStatusChanged", document.Id, document.Status.ToString(), document.FileName, document.FileTypeImageName);`
-
0
Hi,
I still havent managed to get this working.
Do you have any further suggestions?
Thanks.
-
0
Hi @Astech
We have replied to your email. Please let us know if you are still having problems.