Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Uncaught (in promise): Failed to connect. Error: Error during negotiation request #112

Open
SemVC7 opened this issue May 4, 2018 · 2 comments

Comments

@SemVC7
Copy link

SemVC7 commented May 4, 2018

Hi there,

Cannot find a way to make connection from Angular app to ChatHub.

Angular 5 app:
"signalr": "^2.2.3"
"ng2-signalr": "^5.0.0"

app.module.ts -->
image

.net core 2.0 API
"Microsoft.AspNetCore.SignalR (1.0.0-preview2-final)"

Startup.cs -->
image

Error message when i try to connect from my angular app to the hub:

image

Any help would be greatly appreciated!

Thanks in advance,
Sem

@jmwaldrip
Copy link

Try this c.withCredentials = true;

This fixed it for me.

@TomZak
Copy link

TomZak commented Jul 30, 2019

Hello

I have the same problem on my soution. I have an old Service written in C# with .Net-Framework 4.6.1. I included following packages:

"Microsoft.AspNet.Cors" version="5.2.7"
"Microsoft.Owin" version="4.0.1"
"Owin" version="1.0"
"Microsoft.AspNet.SignalR" version="2.4.1"
"Microsoft.AspNet.SignalR" version="2.4.1"

My Startup.cs lookes like:
public class StartUp
{
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
var config = new HubConfiguration
{
EnableJSONP = true,
EnableDetailedErrors = true,
EnableJavaScriptProxies = true
};
app.MapSignalR(config);
}
}

And in the Service.cs I started the Hub with following code:
private Exception Start_SignalR()
{
try
{
var option = new StartOptions("https://10.31.80.41:18277)
{
ServerFactory = "Microsoft.Owin.Host.HttpListener"
};
SignalR = WebApp.Start(option);
}
catch (Exception ex)
{
return ex;
}
return null;
}

Now I want to connect my Angular-App with the Server:
I installed ng2-signalr with following versions:

Angular 7 app:
"signalr": "^2.4.1",
"ng2-signalr": "^8.0.2",

In the app.module.ts i
export function createConfig(): SignalRConfiguration {
const c = new SignalRConfiguration();
c.url = 'https://10.31.80.41:18277';
c.hubName = 'SignalR_Hub';
c.qs = { user: 'zako' };
c.logging = true;
c.executeEventsInZone = true;
c.executeErrorsInZone = true;
c.executeStatusChangeInZone = true;
c.withCredentials = true;
c.transport = [ConnectionTransports.webSockets, ConnectionTransports.longPolling];
c.jsonp = true;
return c;
}

When I change the Urls to "http://localhost:18277" and run it lokal
(VS2019 with the service and VS-Code an Chrome) everything is ok,
but on the server i got following error:

ConnectionResolver. Resolving...
Creating connecting with...
configuration:[url: 'https://10.31.80.41:18277/'] ...
configuration:[hubName: 'SignalR_Hub'] ...
configuration:[qs: '{"user":"zako"}'] ...
configuration:[transport: '[{"_name":"webSockets"},{"_name":"longPolling"}]'] ...
GET https://10.31.80.41:18277//signalr/negotiate?clientProtocol=2.1&user=zako&connectionData=%5B%7B%22name%22%3A%22signalr_hub%22%7D%5D&callback=jQuery34107495844718916238_1564478570288&_=1564478570290
net::ERR_CONNECTION_RESET
Could not connect
ERROR Error: Uncaught (in promise): Failed to connect. Error: Error during negotiation request.

Can me help anyone?

Thanks in advance,
Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants