# Signalr connection problem

**URL:** <https://forum.freecodecamp.org/t/signalr-connection-problem/476853>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 7, 2021, 1:00am UTC](https://forum.freecodecamp.org/t/signalr-connection-problem/476853 "2021-09-07T01:00:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffreyPr](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jeffreyPr](https://forum.freecodecamp.org/u/jeffreyPr)\
**Post date:** [September 7, 2021, 1:00am UTC](https://forum.freecodecamp.org/t/signalr-connection-problem/476853/1 "2021-09-07T01:00:51Z")

</div>

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:

```auto
      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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 8, 2022, 1:01pm UTC](https://forum.freecodecamp.org/t/signalr-connection-problem/476853/2 "2022-03-08T13:01:22Z")

</div>

Closed on March 8, 2022, 1:01pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
