Chat demo doesnt work while running from localhost but works on Azure website:
Error i see in console is:
core.es5.js:1084
ERROR Error: Uncaught (in promise): Failed to connect. Error: Error during negotiation request.
I also tried with Edge browser and it works there, is it related to some version of Chrome browser maybe?
Can you try importing the polyfills to see if it fixes the issue? Looks like someone else ran into this one as well.
Object.assign is where it seems to be blowing up and it might be because it doesn't exist?
Uncomment out these lines in ./Client/polyfills/polyfills.ts and let me know if that fixes it up!
i tried that just now and it didn't help, got the same error:
core.es5.js:1084 ERROR Error: Uncaught (in promise): Failed to connect. Error: Error during negotiation request.
at resolvePromise (zone.js:710) [angular]
at resolvePromise (zone.js:681) [angular]
at dist/main-browser.js?v=ZS8J4QmTynN8IVdN0A8QhbaRMWKoQ2XL_xpgFVdhMW0:118516:17 [angular]
at Object.onInvokeTask (core.es5.js:4116) [angular]
at drainMicroTaskQueue (zone.js:591) [<root>]
at HTMLAnchorElement.ZoneTask.invoke (zone.js:464) [<root>]
I managed to solve this with a few different steps.
1.) Uncommenting the polyfills from polyfills.ts fixed the SignalR error for IE11 but not other browsers.
2.) It turns out there was a bug released with zone.js 0.8.8 (see here: https://github.com/angular/angular-cli/issues/6036). Deleting zone from node modules and upgrading to 0.8.9 fixed SignalR for the other browsers.
Hope this helps!
At first i upgraded zone.js to version 0.8.9 and that didn't help.
After that i did the steps below and now it works!
1) updated node to latest version v7.9.0
2) updated jquery signalr js to v 2.2.1 in _Layout.cshtml
<script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.1.min.js"></script>
3) cleared .awcache and rerun compilation npm run build:dev
Still not sure if it was a cache problem or upgrading some of the dependencies helped but it works for now:)
Thx to @M-R-Bishop for pointing out the zone.js issue.
Great find @M-R-Bishop ! Want to put in a quick PR with the fixes?
also for chat to start sending message to server hub you need to change the order of parameters (user, message) at this line of code:
https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/ClientApp/app/containers/chat/chat.component.ts#L39
So that line should look like this: this._connection.invoke('Chat', new ChatMessage(message, user))
@jerkovicl can you PR this?
You should use HTTPS instead of HTTP.
Because signalR does not support HTTP. If you are using HTTPS, then we should check for another fix.
I am not sure what protocol you are using.
Can you please confirm @jerkovicl
@AbrarJahin since this is still in development (localhost dev project) i am using HTTP, when it goes to production it will be switched to HTTPS
core.es5.js:1084 ERROR Error: Uncaught (in promise): Failed to connect. Error: Error during negotiation request.
at resolvePromise (zone.js:710) [angular]
at resolvePromise (zone.js:681) [angular]
error - due to the fact that: method resolve() takes error from the server, however, it should take only success, add the catch block and the error will disappear
resolve(): Promise<ISignalRConnection> {
return this.signalR.connect().then((item) => {
return item;
}).catch(() => {
return this.router.navigate(['/']);
});
};
Fixed via https://github.com/MarkPieszak/aspnetcore-angular2-universal/commit/469a7a705b8aa8d2f8487c458fb4d625288ffade and https://github.com/MarkPieszak/aspnetcore-angular2-universal/commit/593622f3cbc7cf47047e9109b172334984d6a2d5
These might eventually go into HOW-TO Guide, but just wanted to fix them for now at least.
added to docs meta issue
Most helpful comment
Great find @M-R-Bishop ! Want to put in a quick PR with the fixes?