# Unable to send Stream message

**URL:** https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068
**Category:** Runtime Framework
**Tags:** typescript, server-framework
**Created:** [March 6, 2025, 10:34am UTC](https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068 "2025-03-06T10:34:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)
#### Post date: [March 6, 2025, 10:34am UTC](https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068/1 "2025-03-06T10:34:04Z")

</div>

Hello, I’m trying to use the streamUserSend API to send a notification to one user. I’ve tried this following:

1. 

```auto
      const l = nk.streamUserGet(ctx.userId, ctx.sessionId, globalStream);
      nk.streamSend(globalStream, JSON.stringify({ type: "bot_match", matchId }), [l]);

```

This gives me the following error:

```auto
{"level":"debug","ts":"2025-03-06T14:30:15.933+0400","caller":"server/message_router.go:66","msg":"No session to route to","sid":"00000000-0000-0000-0000-000000000000"}

```

1. 

```auto
      const l = nk.streamUserList(globalStream);
      nk.streamSend(globalStream, JSON.stringify({ type: "bot_match", matchId }), l);

```

This gives the error:

```auto
{"level":"error","ts":"2025-03-06T14:28:02.990+0400","caller":"server/runtime_javascript.go:586","msg":"JavaScript runtime function raised an uncaught exception","mode":"before","id":"*rtapi.envelope_matchmakerremove","error":"TypeError: expects an array of presence objects at github.com/heroiclabs/nakama/v3/server.(*RuntimeJavascriptNakamaModule).mappings.(*RuntimeJavascriptNakamaModule).streamSend.func75 (native)"}

```

Not sure why this isn’t working. I’m calling this from the beforeMatchmakerRemove hook if that helps.

PS: I’m using streamSend over the Notification API because of the reliable option. Does that matter?

Regards

---

<div class="post-metadata">

### Author: ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)
#### Post date: [March 6, 2025, 1:42pm UTC](https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068/2 "2025-03-06T13:42:03Z")

</div>

Hello @MinatoTW,

The error should indicate that the socket connection to the target user is not available anymore.

Either way you should be using the Notification API, the streams APIs are lower level and only meant for things that can’t be achieved using the preferred standard ones.

The underlying socket connections use TCP so the reliable option won’t matter in this case, it’s meant for implementations of rUDP whose support we haven’t made publicly available.

Best.

---

<div class="post-metadata">

### Author: ![MinatoTW](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@MinatoTW](https://forum.heroiclabs.com/u/MinatoTW)
#### Post date: [March 6, 2025, 1:54pm UTC](https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068/3 "2025-03-06T13:54:06Z")

</div>

Thank you. I’m still curious about streamSend though, because I’m the only user logged in and I see the account in the `streamUserGet` response. So there’s no chance it can’t find my session. Also, if I use streamSend without presences it works fine.

---

<div class="post-metadata">

### Author: ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)
#### Post date: [March 6, 2025, 2:11pm UTC](https://forum.heroiclabs.com/t/unable-to-send-stream-message/6068/4 "2025-03-06T14:11:40Z")

</div>

I had misread the error message, it’s possible there’s an input validation bug, but I’m not sure yet.

Could you log a JSON.stringify of `const l` and post it here please?
