Base solution for your next web application
Open Closed

Signalr and Angular 2 #2381


User avatar
0
cangunaydin created

Hello, I am using Asp.Net Zero Core and Angular2 project. When i built it first time it connects to signalr and there is no problem with the connection. But after rebuilds for both ui and .net core end, sometimes it doesn't connect to signalr hub and gives an 500 internal error for the link <a class="postlink" href="http://localhost:22742/signalr/hubs?=1485624235544">http://localhost:22742/signalr/hubs?=1485624235544</a> from the console of the web browser.

I use VS Code for the ui and VS 2015 for the .net core project. Do you have any idea about what can be the problem?


22 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We didn't have such problems but server side was ready for us and we were building UI part most of the time. At the moment, I don't have any idea but I will try this and get back to you.

    Thanks.

  • User Avatar
    0
    tiestop created

    I am having the same issue using Core and Angular 2.0. I have an Azure app service for the client and one for the server. Everything is working fine except signalr.

    I am getting the following message in the chrome console

    {azure-app-service-endpoint}hubs?_=1485791190035 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

    This is the stacktrace

    System.NotSupportedException: The invoked member is not supported in a dynamic assembly. at System.Reflection.Emit.InternalAssemblyBuilder.get_Location() at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.GetTypesSafe(Assembly a) at System.Linq.Enumerable.<SelectManyIterator>d__162.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.BuildHubsCache() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.GetHubs() at System.Linq.Enumerable.<SelectManyIterator>d__162.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable1.<GetEnumerator>d__1.MoveNext() at Microsoft.AspNet.SignalR.Hubs.DefaultJavaScriptProxyGenerator.GenerateProxy(IHubManager hubManager, IJavaScriptMinifier javaScriptMinifier, Boolean includeDocComments) at System.Lazy1.CreateValue() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Lazy1.get_Value() at Microsoft.AspNet.SignalR.Hubs.DefaultJavaScriptProxyGenerator.GenerateProxy(String serviceUrl) at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) at Microsoft.Owin.Cors.CorsMiddleware.<Invoke>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.Mapping.MapMiddleware.<Invoke>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.AspNetCore.Owin.WebSocketAcceptAdapter.<>c__DisplayClass6_0.<<AdaptWebSockets>b__0>d.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.AspNetCore.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @tiestop,

    Sorry for the late reply, I was trying to find the solution for this. I have managed to work this out and below are the steps I have applied.

    1. Add a reference to "Owin.Security.AesDataProtectorProvider" nuget package to your .Host project and add below line to your ConfigureOwinServices method in Startup.cs right after app.UseAbp();
    app.UseAesDataProtectorProvider();
    

    This will solve the first problem which is related to data protection.

    1. After first step, in your Angular2 solution, you need to change signalr start code in abp.signalr.js file like this.
    $.connection.hub.start({ withCredentials: false })
    

    Only change here is adding { withCredentials: false } when starting a hub. There are two places in abp.signalr.js which starts signalr hub, change those two places and upload both projects again and see if that works for you as well.

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please ignore the 2. step in my answer. We are still tyring to make this for. I will let you know the result of our work.

  • User Avatar
    0
    cangunaydin created

    Hello thank you for the effort, is there any progress for this problem? i did the first step of the solution but i am still getting the same error.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Yes, probably we will fix this soon. We are just trying to find the best solution.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This took longer than we expected but it is solved now, sorry for this. You can apply changes we made for this issue <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/47">https://github.com/aspnetzero/aspnet-ze ... /issues/47</a>.

    Or you can wait for our next release. It will be today or tomorrow.

    Thanks.

  • User Avatar
    0
    brallierc created

    How do I access your github? brallierc is my user account

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It seems like you are already invited on github. Probably you didn't receive invitation email, it happens sometimes.

    Please visit this address to accept invitation <a class="postlink" href="https://github.com/orgs/aspnetzero">https://github.com/orgs/aspnetzero</a> to accept invitation and then you should be able to see that issue.

    Thanks.

  • User Avatar
    0
    cangunaydin created

    Hello, I have downloaded and migrated my project to the new release but still i am getting this error. Here is the error from the logfile.

    ERROR 2017-02-17 14:53:26,236 [14   ] Microsoft.AspNetCore.Server.Kestrel      - Connection id "0HL2N5D0VKP1A": An unhandled exception was thrown by the application.
    System.NotSupportedException: The invoked member is not supported in a dynamic assembly.
       at System.Reflection.Emit.InternalAssemblyBuilder.get_Location()
       at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.GetTypesSafe(Assembly a)
       at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.BuildHubsCache()
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.GetHubs()
       at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.OrderedEnumerable`1.&lt;GetEnumerator&gt;d__1.MoveNext()
       at Microsoft.AspNet.SignalR.Hubs.DefaultJavaScriptProxyGenerator.GenerateProxy(IHubManager hubManager, IJavaScriptMinifier javaScriptMinifier, Boolean includeDocComments)
       at System.Lazy`1.CreateValue()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Lazy`1.get_Value()
       at Microsoft.AspNet.SignalR.Hubs.DefaultJavaScriptProxyGenerator.GenerateProxy(String serviceUrl)
       at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context)
       at Microsoft.Owin.Cors.CorsMiddleware.&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.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.AspNetCore.Owin.WebSocketAcceptAdapter.&lt;&gt;c__DisplayClass6_0.&lt;&lt;AdaptWebSockets&gt;b__0>d.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.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.&lt;Invoke&gt;d__18.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.AspNetCore.Cors.Infrastructure.CorsMiddleware.&lt;Invoke&gt;d__7.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.AspNetCore.Localization.RequestLocalizationMiddleware.&lt;Invoke&gt;d__4.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.AspNetCore.Server.IISIntegration.IISMiddleware.&lt;Invoke&gt;d__8.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.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.&lt;Invoke&gt;d__3.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.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you get the same error message on your local environment ? Can you also share your project with us via <a href="mailto:[email protected]">[email protected]</a>. We can find a faster solution in this way I think.

    Thanks.

  • User Avatar
    0
    cangunaydin created

    I have sent an email. you can download it from the link there. Thank you for the help again.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks, I have got the project. We will try it and get back to you as soon as possible.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have tested your project on local and azure websites and it seems like signalR is connection. There might be something wrong with the configuration.

    "WebSiteRootAddress" in your host project's appsettings.json must be set to your angular2 client app's address. Did you set it like this ?

  • User Avatar
    0
    cangunaydin created

    Yes the configuration is right, i am running the project that i have sent you so i didn't change any configuration. As i said sometimes it connects sometimes it does not. It is kind of weird actually after some rebuilds it does not connect anymore maybe it is about the session or sth?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Does this happens both on your local machine and azure ? If you have deployed it to azure, can you share it's address and a test user credentials via email ?

    Thanks.

  • User Avatar
    0
    cangunaydin created

    No it's not on azure i am not deploying it to azure. Only on my local machine it happens.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks, there was a missunderstanding then :). Normally signalr tries to reconnect even if it fails. We will test it today.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @cangunaydin,

    Finanly we reproduced this problem and we have fixed it. You can see the solution here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/116">https://github.com/aspnetzero/aspnet-ze ... issues/116</a>.

  • User Avatar
    0
    cangunaydin created

    Oh thank you for the update. I will fix it on my own project also. Cheers @ismcagdas

  • User Avatar
    0
    vishnue created

    We have the same issue, but I can't seem to access the fix on Github. How can I access to the solution?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @vishnue,

    Please share your github username with us and we will invite you to private repository, so you can see that link. You can send it to <a href="mailto:[email protected]">[email protected]</a>

    Thanks.