every time i try to invoke the signalr connection i get a error message:
Unhandled Rejection (Error): Cannot send data if the connection is not in the ‘Connected’ State.
while the first thing i do is to start the connection:
useEffect(() => {
const Connection = new HubConnectionBuilder()
.withUrl('https://localhost:44332/chatHub')
.withAutomaticReconnect()
.build();
setNewConnection(Connection)
Connection.start().then(result => { console.log("connected")});
Connection.invoke("JoinGroup", "PrivateGroup");
Connection.on("ReceiveMessage", (message) => {
setTestName(message)})
},[]);
i get a message in the console saying: connected wich means that Signalr is connected
so i dont understand why it has problems sending data if it would be connected.
the backend code is also completely fine.