Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

SignalR .Net Client fails with 500 server error on device, on simulator works fine

$
0
0

I'm trying to implement a chat in my app, with azure asp.net web api on back-end and xamarin ios on front-end.

So on back-end I configure my hub with this lines:

            var hubConfiguration = new HubConfiguration();
            hubConfiguration.EnableDetailedErrors = true;
            app.MapSignalR("/signalr", hubConfiguration);

and here is my hub source:

    [HubName("Chat")]
    public class Chat : Hub
    {

        public Task JoinRoom(string roomName)
        {
            return Groups.Add(Context.ConnectionId, roomName);
        }

        public Task LeaveRoom(string roomName)
        {
            return Groups.Remove(Context.ConnectionId, roomName);
        }

        public Task Send(string message, string room)
        {
            return Clients.OthersInGroup(room).addMessage(message);
        }
    }

on xamarin ios client everything is pretty simple too:

    [Preserve(AllMembers=true)]
    public class Msg
    {
        public string txt { get; set; }
    }

    public class Client
    {
        private readonly string _userName;
        private readonly HubConnection _connection;
        private readonly IHubProxy _proxy;

        public event EventHandler<string> OnMessageReceived;

        public Client(string userName)
        {
            _userName = userName;
            _connection = new HubConnection("http://mywebsite.azurewebsites.net/");
            _connection.ConnectionToken = NetManager.Instance.token.access_token;
            _proxy = _connection.CreateHubProxy("Chat");
        }

        public async Task Connect()
        {

            await _connection.Start();

            _proxy.On("messageReceived", (Msg platform, Msg message) =>
                {
                    if (OnMessageReceived != null)
                        OnMessageReceived(this, string.Format("{0}: {1}", platform, message));
                });

            Send("Connected");
        }

        public Task Send(string message)
        {
            return _proxy.Invoke("Send", _userName, message);
        }
    }

So if I connect to server from ios simulator -- it works fine, but when I try to do this from my ipad device -- it crashes with internal server error on line ('await _connection.Start();')

I have already checked server with debugger, but no exceptions raised there, and logs are clear.

Any ideas how to fix this will be very helpful!

Found some server logs:

> <Data>http://ibyb.azurewebsites.net/signalr/negotiate?clientProtocol=1.4&amp;connectionData=[{}]&amp;noCache=f4b45891-721f-4806-a29c-e4eacc176221</Data><Data>/signalr/negotiate</Data><Data>89.179.240.94</Data><Data></Data><Data>False</Data><Data></Data><Data>IIS APPPOOL\ibyb</Data><Data>19</Data><Data>IIS
> APPPOOL\ibyb</Data><Data>False</Data><Data>   at
> System.Collections.Generic.Dictionary`2.FindEntry(TKey key)    at
> Microsoft.AspNet.SignalR.Hubs.HubDispatcher.AuthorizeRequest(IRequest
> request)    at
> Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2
> environment)    at
> Microsoft.AspNet.SignalR.Owin.Middleware.HubDispatcherMiddleware.Invoke(IOwinContext
> context)    at
> Microsoft.Owin.Infrastructure.OwinMiddlewareTransition.Invoke(IDictionary`2
> environment)    at
> Microsoft.Owin.Mapping.MapMiddleware.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.Owin.Security.Infrastructure.AuthenticationMiddleware`1.&lt;Invoke&gt;d__0.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.AspNet.Identity.Owin.IdentityFactoryMiddleware`2.&lt;Invoke&gt;d__0.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.AspNet.Identity.Owin.IdentityFactoryMiddleware`2.&lt;Invoke&gt;d__0.MoveNext()
> --- End of stack trace from previous location where exception was thrown ---    at
> Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult
> ar)    at
> Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult
> ar)    at
> System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
> at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
> Boolean&amp; completedSynchronously) </Data>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>