SignalR with asp.net 3.1 and flutter app is working fine with local server but its not working on live server. I/flutter (28526): HubConnection connected successfully. I/flutter (28526): BTJiJtOdpGPjUyvYAzb4sA I/flutter (28526): Connection state 'HubConnectionState.connected' I/flutter (28526): notification received from server I/flutter (28526): (SSE transport) sending data. String data of length '11'. I/flutter (28526): (SSE transport) request complete. Response status: 404.
Startup.cs
services.AddSignalR(e =>
{
e.MaximumReceiveMessageSize = 102400000;
e.EnableDetailedErrors = true;
e.KeepAliveInterval = TimeSpan.FromMinutes(60);
e.EnableDetailedErrors = true;
});
app.UseCors("CorsPolicy");
app.UseCookiePolicy();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<ChatHubs>("/chathub");
});
At flutter side with signalr_core: ^1.1.1
hubConnection = HubConnectionBuilder().withUrl(ApisUrls.baseUrl+"/chathub", HttpConnectionOptions(
accessTokenFactory: () async => await headerHelper.gettokenWithoutBearer(),
logging:(level, message) => print(message),
)
).withAutomaticReconnect().build();
// hubConnection.serverTimeoutInMilliseconds = 60000;
if (hubConnection.state != HubConnectionState.connected) {
await hubConnection.start();
print('${hubConnection.connectionId}');
setState(() {
});
}
// When the connection is closed, print out a message to the console.
hubConnection.onclose( (error) => print("Connection Closed"));
hubConnection.on("ReceiveMessage", _handleAClientProvidedFunction);
hubConnection.on("OnConnectedAsync", _onConnectFunction);
hubConnection.on("OnDisConnectedAsync", _onDisConnectFunction);
class ApisUrls {
// static final baseUrl = "http://localhost:57712"; // local api// local api
static final baseUrl = "http://185.249.225.188:5005";
}