Comments (7)
The XMLHttpRequest error is due to Cors policy issue. I managed to solve it by doing the next steps in a C# application.
1- Define in your startup.cs file a new porperty ie:
readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
2-At your configure method in the same Startup.cs file add the next line to add Cors
services.AddCors(options => { options.AddPolicy(MyAllowSpecificOrigins, policy => { policy.WithOrigins("http://localhost:58944") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); });
Where WithOrigins must be filled with the UI host url you are trying to send the message from.
3- Use Cors at your Configure method in the same Startup.cs file
app.UseCors(MyAllowSpecificOrigins); app.UseRouting();
It must be defined before UseRouting method.
Please give it a shot and let everyone know if this worked out for you.
from signalr_core.
I have the same problem. Any information on when it will be fixed?
from signalr_core.
Same issue, these plugin not working on flutter web , Any Idea till when it will going to be fixed?
from signalr_core.
@jamiewest Hi !
I bumped into this same error but I found a different solution that does not involve configuring 'CORS'.
final connection = HubConnectionBuilder() .withUrl( 'http://localhost:9670/hub', HttpConnectionOptions( skipNegotiation: true, transport: HttpTransportType.webSockets, logging: (level, message) => print(message), )) .build();
You can simply set skipNegotiation to true, but when reading the docs on the microsoft site (https://docs.microsoft.com/en-us/javascript/api/%40aspnet/signalr/ihttpconnectionoptions?view=signalr-js-latest#skipnegotiation) , it says that you have to be using Web Sockets for this to work.
By the way what are the downsides to setting skipNegotiation to true, any security issues or something?
Environment
Flutter 2.8.0
.Net 5
from signalr_core.
services.AddCors(op =>
{
op.AddPolicy("SignalRCors", set =>
{
set.SetIsOriginAllowed(origin => true)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
from signalr_core.
@AmbujaAK maybe try to look there
#24 (comment)
from signalr_core.
Allowing Cors solved it for me too. But the port could change between runs so I made the server code a bit more generic.
In .NET you could use the following:
services.AddCors(options => { options.AddPolicy(MyAllowSpecificOrigins, builder => builder.SetIsOriginAllowed(origin => new Uri(origin).IsLoopback) ); });
from signalr_core.
Related Issues (20)
- Upgrade http dependency HOT 5
- How to create builder with Header?
- Exception: The underlying connection was closed before the hub handshake could complete.
- BadState: Future already completed after calling _stopConnection
- signalr_core 1.1.1 depends on http ^0.13.0 HOT 2
- InvalidOperationException: Sequence contains no matching element HOT 1
- Unhandled Exception: Exception: HttpConnection.stopConnection(Exception: WebSocket closed with status code: 1002 (null).) was called while the connection is still in the connecting state. HOT 1
- signalr_core >=1.1.0 <1.1.2 depends on http ^0.13.0
- How to add proxy to HubConnectionBuilder?
- Retry lost connection forever?
- Server timeout after 30 seconds with long polling transport
- Stop method is not working
- Problem with HTTPS url HOT 4
- Please make this change in your code HOT 2
- Hubconnection.stop() take too long time
- Run signalR in background native service (Java et Kt)
- What is the proper way to subscribe on the events in SignalR?
- The underlying connection was closed before the hub handshake could complete. HOT 1
- Future Plans HOT 8
- JavaScript error on laptop sleep only in release web build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from signalr_core.