externalMedia not sending any packets

Hey! I’m creating a simple demo for my work and I’m struggling with sending audio stream to rtc udp server.
I’ve got working example of creating a snoopChannel and playing back audio, but externalMedia is not sending any data to server.
extension.conf:

[from-internal]
exten = 100,1,NoOp()
same = n,Stasis(bun-app)
same = n,Hangup()

Node app with ari-client:

ari.on("StasisStart", async (ev, ch) => {
  if (ev.channel.caller.number === "") return;

  console.log("Channel entered Stasis application");

  try {
    await ch.answer();
    await play(ch, "sound:hello-world");

    const mixingBridge = await createMixingBridge();
    mixingBridge.addChannel({ channel: ch.id });

    const snoopingChannel = await ch.snoopChannelWithId({
      app: "bun-app",
      appArgs: "snooping",
      snoopId: `snoop-${ch.id}`,
      spy: "in",
      whisper: "out",
    });

    await mixingBridge.addChannel({
      channel: snoopingChannel.id,
    });

    const externalMedia = await snoopingChannel.externalMedia({
      app: "bun-app",
      external_host: "localhost:9999",
      format: "ulaw",
    });
  } catch (e) {
    console.log("An error occured:", e);
  }
});

What happens here is:

  1. When we receive call we answer it and play hello-world
  2. We create a mixing bridge and we add initial channel to it (createMixingBridge function creates a bridge and destroys it when every channel has left)
  3. We create snooping channel from initial channel (spy = in, whisper = out)
  4. Snooping channel is added to mixing bridge
  5. External media session is started

With provided example I get my voice played back as I speak into the mic.

For rtp udp server I’m using the one provided in external media example with console log on message event.
I don’t know what I’m missing, but rtp udp server is not getting any messages.
I’ve looked at bunch of examples and I can’t wrap my head around it.

Maybe @mbradeen can help but most of the team is out today so it’ll probably be Monday before he can respond.

1 Like

Thank you for the response! I’ve actually solved this right now, I’ve replaced localhost:9999 with 127.0.0.1:9999 and it started working. I’ve changed a bunch of things in the end, but hostname was what fixed my issue