Asp.Net Core SignalR + Angular 6 issue












0














I have a WebApi that was made using Asp.net Core 2.0 and consuming this API an Angular 5 App. Now I'm making a new version of this App using Angular 6.



In this Web API I use SignalR 1.0.0-alpha-final and in the Angular 5 app I use this as client "@aspnet/signalr-client": "^1.0.0-alpha2-final".



In the old Angular App everything works fine as intended. My problem is that I can use this package on the new version of my app:



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @aspnet/signalr-client@1.0.0-alpha2-update1 install: `echo "This package has been deprecated. Use '@aspnet/signalr' instead." && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @aspnet/signalr-client@1.0.0-alpha2-update1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Then I try to use the recommended version, I follow this article and everything runs OK on the Angular 6 App side, but it never actually connects to the Hub. this is the message I get when running my local Angular APP:



Access to XMLHttpRequest at 'http://localhost:27081/hub/notification/negotiate?jwttoken=the_token_here' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.


It's not a real CORS problem, I made the WebAPI and and Angular APP run in the same domain and I never had CORS problem in my old App. I have the right Cors policies to allow localhost to use the api.



It's weird that the client added negotiate to the connection URL and even If I make my hub answer in this address I get error 400 with this message: Connection ID required



I do believe that this Client Library was made to another version than the one I have on the server, since the client and server has to follow the same version.



I tried using the node_modules from the older Angular App but I cannot get it to compile.. I don't know what to do. Has anyone experienced this issue and managed to solve? Any tips? I can't update the version on the WebAPI or I'll make the current App stop working.



Thanks for any help










share|improve this question






















  • Try matching the @aspnet/signalr version in angular side to that in .net core side.
    – User3250
    Nov 23 '18 at 2:06










  • @User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
    – André Luiz
    Nov 23 '18 at 2:23










  • Yes, in package.json and nuget package.
    – User3250
    Nov 23 '18 at 2:31










  • @User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
    – André Luiz
    Nov 23 '18 at 2:49










  • Do that, I had kind a similar issue so I matched the versions and it worked.
    – User3250
    Nov 23 '18 at 2:54
















0














I have a WebApi that was made using Asp.net Core 2.0 and consuming this API an Angular 5 App. Now I'm making a new version of this App using Angular 6.



In this Web API I use SignalR 1.0.0-alpha-final and in the Angular 5 app I use this as client "@aspnet/signalr-client": "^1.0.0-alpha2-final".



In the old Angular App everything works fine as intended. My problem is that I can use this package on the new version of my app:



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @aspnet/signalr-client@1.0.0-alpha2-update1 install: `echo "This package has been deprecated. Use '@aspnet/signalr' instead." && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @aspnet/signalr-client@1.0.0-alpha2-update1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Then I try to use the recommended version, I follow this article and everything runs OK on the Angular 6 App side, but it never actually connects to the Hub. this is the message I get when running my local Angular APP:



Access to XMLHttpRequest at 'http://localhost:27081/hub/notification/negotiate?jwttoken=the_token_here' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.


It's not a real CORS problem, I made the WebAPI and and Angular APP run in the same domain and I never had CORS problem in my old App. I have the right Cors policies to allow localhost to use the api.



It's weird that the client added negotiate to the connection URL and even If I make my hub answer in this address I get error 400 with this message: Connection ID required



I do believe that this Client Library was made to another version than the one I have on the server, since the client and server has to follow the same version.



I tried using the node_modules from the older Angular App but I cannot get it to compile.. I don't know what to do. Has anyone experienced this issue and managed to solve? Any tips? I can't update the version on the WebAPI or I'll make the current App stop working.



Thanks for any help










share|improve this question






















  • Try matching the @aspnet/signalr version in angular side to that in .net core side.
    – User3250
    Nov 23 '18 at 2:06










  • @User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
    – André Luiz
    Nov 23 '18 at 2:23










  • Yes, in package.json and nuget package.
    – User3250
    Nov 23 '18 at 2:31










  • @User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
    – André Luiz
    Nov 23 '18 at 2:49










  • Do that, I had kind a similar issue so I matched the versions and it worked.
    – User3250
    Nov 23 '18 at 2:54














0












0








0







I have a WebApi that was made using Asp.net Core 2.0 and consuming this API an Angular 5 App. Now I'm making a new version of this App using Angular 6.



In this Web API I use SignalR 1.0.0-alpha-final and in the Angular 5 app I use this as client "@aspnet/signalr-client": "^1.0.0-alpha2-final".



In the old Angular App everything works fine as intended. My problem is that I can use this package on the new version of my app:



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @aspnet/signalr-client@1.0.0-alpha2-update1 install: `echo "This package has been deprecated. Use '@aspnet/signalr' instead." && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @aspnet/signalr-client@1.0.0-alpha2-update1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Then I try to use the recommended version, I follow this article and everything runs OK on the Angular 6 App side, but it never actually connects to the Hub. this is the message I get when running my local Angular APP:



Access to XMLHttpRequest at 'http://localhost:27081/hub/notification/negotiate?jwttoken=the_token_here' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.


It's not a real CORS problem, I made the WebAPI and and Angular APP run in the same domain and I never had CORS problem in my old App. I have the right Cors policies to allow localhost to use the api.



It's weird that the client added negotiate to the connection URL and even If I make my hub answer in this address I get error 400 with this message: Connection ID required



I do believe that this Client Library was made to another version than the one I have on the server, since the client and server has to follow the same version.



I tried using the node_modules from the older Angular App but I cannot get it to compile.. I don't know what to do. Has anyone experienced this issue and managed to solve? Any tips? I can't update the version on the WebAPI or I'll make the current App stop working.



Thanks for any help










share|improve this question













I have a WebApi that was made using Asp.net Core 2.0 and consuming this API an Angular 5 App. Now I'm making a new version of this App using Angular 6.



In this Web API I use SignalR 1.0.0-alpha-final and in the Angular 5 app I use this as client "@aspnet/signalr-client": "^1.0.0-alpha2-final".



In the old Angular App everything works fine as intended. My problem is that I can use this package on the new version of my app:



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @aspnet/signalr-client@1.0.0-alpha2-update1 install: `echo "This package has been deprecated. Use '@aspnet/signalr' instead." && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @aspnet/signalr-client@1.0.0-alpha2-update1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Then I try to use the recommended version, I follow this article and everything runs OK on the Angular 6 App side, but it never actually connects to the Hub. this is the message I get when running my local Angular APP:



Access to XMLHttpRequest at 'http://localhost:27081/hub/notification/negotiate?jwttoken=the_token_here' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.


It's not a real CORS problem, I made the WebAPI and and Angular APP run in the same domain and I never had CORS problem in my old App. I have the right Cors policies to allow localhost to use the api.



It's weird that the client added negotiate to the connection URL and even If I make my hub answer in this address I get error 400 with this message: Connection ID required



I do believe that this Client Library was made to another version than the one I have on the server, since the client and server has to follow the same version.



I tried using the node_modules from the older Angular App but I cannot get it to compile.. I don't know what to do. Has anyone experienced this issue and managed to solve? Any tips? I can't update the version on the WebAPI or I'll make the current App stop working.



Thanks for any help







asp.net angular signalr






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 1:21









André Luiz

1,11321545




1,11321545












  • Try matching the @aspnet/signalr version in angular side to that in .net core side.
    – User3250
    Nov 23 '18 at 2:06










  • @User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
    – André Luiz
    Nov 23 '18 at 2:23










  • Yes, in package.json and nuget package.
    – User3250
    Nov 23 '18 at 2:31










  • @User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
    – André Luiz
    Nov 23 '18 at 2:49










  • Do that, I had kind a similar issue so I matched the versions and it worked.
    – User3250
    Nov 23 '18 at 2:54


















  • Try matching the @aspnet/signalr version in angular side to that in .net core side.
    – User3250
    Nov 23 '18 at 2:06










  • @User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
    – André Luiz
    Nov 23 '18 at 2:23










  • Yes, in package.json and nuget package.
    – User3250
    Nov 23 '18 at 2:31










  • @User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
    – André Luiz
    Nov 23 '18 at 2:49










  • Do that, I had kind a similar issue so I matched the versions and it worked.
    – User3250
    Nov 23 '18 at 2:54
















Try matching the @aspnet/signalr version in angular side to that in .net core side.
– User3250
Nov 23 '18 at 2:06




Try matching the @aspnet/signalr version in angular side to that in .net core side.
– User3250
Nov 23 '18 at 2:06












@User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
– André Luiz
Nov 23 '18 at 2:23




@User3250 How do I do that? you mean in the package.json? "@aspnet/signalr": "1.0.4",
– André Luiz
Nov 23 '18 at 2:23












Yes, in package.json and nuget package.
– User3250
Nov 23 '18 at 2:31




Yes, in package.json and nuget package.
– User3250
Nov 23 '18 at 2:31












@User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
– André Luiz
Nov 23 '18 at 2:49




@User3250 I tried all the older version on NPM and they do the same thing. I'll try to update on the API to a version that works with both App
– André Luiz
Nov 23 '18 at 2:49












Do that, I had kind a similar issue so I matched the versions and it worked.
– User3250
Nov 23 '18 at 2:54




Do that, I had kind a similar issue so I matched the versions and it worked.
– User3250
Nov 23 '18 at 2:54












2 Answers
2






active

oldest

votes


















1














I just got to make it work without changing the version of the webapi. This is how I make the connection:



this._hubConnection = new signalR.HubConnectionBuilder()
.withUrl('http://localhost:27081/hub/notification/?jwttoken='+ this.jwt,
{
accessTokenFactory: ()=> this.jwt ,
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.build();


That's all. Yes, in the version I have in the API i have to send the token in the querysting. This documentation helped me achieve that.






share|improve this answer





























    0














    You should update to the latest .Net core SignalR if you can



    This include the client script @aspnet/signalR (currently 1.0.4)



    With the latest Nuget Package Microsoft.AspNetCore.SignalRCore (currently 1.0.4)



    Also note that initialising the hub in javascript changed from the preview version, looks something like this:



    var connection = new signalR.HubConnectionBuilder().withUrl("/yourhub/").build();





    share|improve this answer





















    • I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
      – André Luiz
      Nov 23 '18 at 11:29











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439644%2fasp-net-core-signalr-angular-6-issue%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I just got to make it work without changing the version of the webapi. This is how I make the connection:



    this._hubConnection = new signalR.HubConnectionBuilder()
    .withUrl('http://localhost:27081/hub/notification/?jwttoken='+ this.jwt,
    {
    accessTokenFactory: ()=> this.jwt ,
    skipNegotiation: true,
    transport: signalR.HttpTransportType.WebSockets
    })
    .build();


    That's all. Yes, in the version I have in the API i have to send the token in the querysting. This documentation helped me achieve that.






    share|improve this answer


























      1














      I just got to make it work without changing the version of the webapi. This is how I make the connection:



      this._hubConnection = new signalR.HubConnectionBuilder()
      .withUrl('http://localhost:27081/hub/notification/?jwttoken='+ this.jwt,
      {
      accessTokenFactory: ()=> this.jwt ,
      skipNegotiation: true,
      transport: signalR.HttpTransportType.WebSockets
      })
      .build();


      That's all. Yes, in the version I have in the API i have to send the token in the querysting. This documentation helped me achieve that.






      share|improve this answer
























        1












        1








        1






        I just got to make it work without changing the version of the webapi. This is how I make the connection:



        this._hubConnection = new signalR.HubConnectionBuilder()
        .withUrl('http://localhost:27081/hub/notification/?jwttoken='+ this.jwt,
        {
        accessTokenFactory: ()=> this.jwt ,
        skipNegotiation: true,
        transport: signalR.HttpTransportType.WebSockets
        })
        .build();


        That's all. Yes, in the version I have in the API i have to send the token in the querysting. This documentation helped me achieve that.






        share|improve this answer












        I just got to make it work without changing the version of the webapi. This is how I make the connection:



        this._hubConnection = new signalR.HubConnectionBuilder()
        .withUrl('http://localhost:27081/hub/notification/?jwttoken='+ this.jwt,
        {
        accessTokenFactory: ()=> this.jwt ,
        skipNegotiation: true,
        transport: signalR.HttpTransportType.WebSockets
        })
        .build();


        That's all. Yes, in the version I have in the API i have to send the token in the querysting. This documentation helped me achieve that.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 16:11









        André Luiz

        1,11321545




        1,11321545

























            0














            You should update to the latest .Net core SignalR if you can



            This include the client script @aspnet/signalR (currently 1.0.4)



            With the latest Nuget Package Microsoft.AspNetCore.SignalRCore (currently 1.0.4)



            Also note that initialising the hub in javascript changed from the preview version, looks something like this:



            var connection = new signalR.HubConnectionBuilder().withUrl("/yourhub/").build();





            share|improve this answer





















            • I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
              – André Luiz
              Nov 23 '18 at 11:29
















            0














            You should update to the latest .Net core SignalR if you can



            This include the client script @aspnet/signalR (currently 1.0.4)



            With the latest Nuget Package Microsoft.AspNetCore.SignalRCore (currently 1.0.4)



            Also note that initialising the hub in javascript changed from the preview version, looks something like this:



            var connection = new signalR.HubConnectionBuilder().withUrl("/yourhub/").build();





            share|improve this answer





















            • I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
              – André Luiz
              Nov 23 '18 at 11:29














            0












            0








            0






            You should update to the latest .Net core SignalR if you can



            This include the client script @aspnet/signalR (currently 1.0.4)



            With the latest Nuget Package Microsoft.AspNetCore.SignalRCore (currently 1.0.4)



            Also note that initialising the hub in javascript changed from the preview version, looks something like this:



            var connection = new signalR.HubConnectionBuilder().withUrl("/yourhub/").build();





            share|improve this answer












            You should update to the latest .Net core SignalR if you can



            This include the client script @aspnet/signalR (currently 1.0.4)



            With the latest Nuget Package Microsoft.AspNetCore.SignalRCore (currently 1.0.4)



            Also note that initialising the hub in javascript changed from the preview version, looks something like this:



            var connection = new signalR.HubConnectionBuilder().withUrl("/yourhub/").build();






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 7:15









            Mark Redman

            16.3k1779122




            16.3k1779122












            • I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
              – André Luiz
              Nov 23 '18 at 11:29


















            • I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
              – André Luiz
              Nov 23 '18 at 11:29
















            I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
            – André Luiz
            Nov 23 '18 at 11:29




            I did it and still didn't work. I set 1.0.4 on the API and then 1.0.4 on the client. Right now I'm rushing on a delivery, but I'll start and APP from zero just to test that because I suspect of some sort of cache or something like this,
            – André Luiz
            Nov 23 '18 at 11:29


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439644%2fasp-net-core-signalr-angular-6-issue%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...