I use ASP.Net framework to host the socket server. I created a Hub using SignalR, i ran it and then tried to connect to it from my angular app but recieved this error:
Failed to start the connection: TypeError: Cannot read properties of undefined (reading 'length')
There are no more details. I Enabled CORS with this code:
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR("/Art", new HubConfiguration());
}
and in the hub:
[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")]
public class ArtHub : Hub
{
....
}
I will highly appreciate any help
In configuration of your server use this to see detailed error info:
builder.Services.AddSignalR(o =>
{
o.EnableDetailedErrors = true;
});
Use SignalR Hub endpoint like this:
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<ArtHub>("/art");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.