microsoftgraph / microsoftgraph/microsoft-graph-comms-samples

Media Platform Failed , Adress is alredy in use

Open
#853 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
253
Forks
275
Avg merge
1d 5h
Merged PRs (30d)
1

Description

I’m running a Microsoft Graph Calling/Recording Bot (Application-Hosted Media) as a self-hosted .NET 6 app on Windows Server using Kestrel (console exe / Windows Service).

The app starts and Kestrel binds correctly, ICommunicationsClient begins building, but during CommunicationsClientBuilder.Build() the SDK calls MediaPlatform.Initialize() and it fails with:

SkypeMediaException: Address already in use

This happens even though Kestrel and MediaPlatform are configured on different ports.

Environment

OS: Windows Server (self-hosted)

Runtime: .NET 6.0

Hosting: Kestrel (NOT IIS)

Scenario: Application-Hosted Media (Graph Calling/Recording Bot)

SDK Versions

Microsoft.Graph.Communications.Calls.Media: 1.2.0.5304

Microsoft.Graph.Communications.Client: 1.2.0.5304

Microsoft.Graph.Communications.Core: 1.2.0.5304

Microsoft.Skype.Bots.Media: 1.31.0.225-preview

Expected behavior

Kestrel binds http://127.0.0.1:5000 for bot callbacks/notifications

MediaPlatform binds media ports starting from 8445

Both should coexist without conflicts

MediaPlatform.Initialize() should succeed

Actual behavior

Kestrel starts successfully on port 5000

CommunicationsClientBuilder.Build() triggers media init

Media init fails with Address already in use

MediaPlatform Settings (Startup.cs)
var mediaPlatformSettings = new MediaPlatformSettings
{
ApplicationId = "<APP_ID>",
MediaPlatformInstanceSettings = new MediaPlatformInstanceSettings
{
CertificateThumbprint = "<**************>",
InstanceInternalPort = ******,
InstancePublicPort = **,
InstancePublicIPAddress = IPAddress.Any,
ServiceFqdn = "bot.example.com",
MediaPortRange = new PortRange(
, ****)
}
};

var notificationUrl = new Uri("https://bot.example.com/callback");
var serviceBaseUrl = new Uri("https://127.0.0.1:9443/");

var builder = new CommunicationsClientBuilder(
"MyBot",
"<APP_ID>",
graphLogger)
.SetAuthenticationProvider(authProvider)
.SetNotificationUrl(notificationUrl)
.SetServiceBaseUrl(serviceBaseUrl)
.SetMediaPlatformSettings(mediaPlatformSettings);

var client = builder.Build(); // ❌ fails: Address already in use

Initialization timing

I tried deferring MediaPlatform initialization until after Kestrel is listening:

public class MediaPlatformHostedService : IHostedService
{
public Task StartAsync(CancellationToken cancellationToken)
{
_lifetime.ApplicationStarted.Register(() =>
{
var communicationsClient =
_serviceProvider.GetRequiredService();
});

    return Task.CompletedTask;
}

}

But Build() still fails once it reaches MediaPlatform.Initialize().

Logs (simplified)
[INF] Kestrel is listening on port 5000
[INF] Initializing Media Platform
[INF] InstanceInternalPort=8445, InstancePublicPort=8445
[CRT] SkypeMediaException: Address already in use

Checks already done

Certificate installed in LocalMachine\My and thumbprint is correct

Firewall rules allow UDP traffic for the media range

Verified no other process is using ports 5000, 8445, or 9443

Running as admin / service account with required permissions

Questions
ServiceBaseUrl

Does SetServiceBaseUrl() affect local port binding?

If I set https://127.0.0.1:internal-port/, can MediaPlatform attempt to bind to ***** internally?

What is the correct ServiceBaseUrl for a Kestrel self-hosted bot?

Should it match the public bot URL (e.g., https://bot.example.com/) instead of localhost?

Windows / HTTP.sys

Can there be a conflict with HTTP.sys?

Do Kestrel + MediaPlatform share URLACL reservations?

Does MediaPlatform require “exclusive” binding behavior that can collide even when ports differ?

Port usage rules

Are InstanceInternalPort and InstancePublicPort both being 8445 correct?

Should MediaPortRange start at a different port than InstanceInternalPort?

Initialization behavior

Does MediaPlatform.Initialize() bind ports immediately during Build()?

Is there any supported way to separate “build client” from “bind media sockets”?

Known issues / workarounds

Any known bugs or constraints when running MediaPlatform alongside Kestrel (non-IIS) on Windows Server?

What I’m asking for

The correct SetServiceBaseUrl() value for Kestrel self-hosted deployments

Confirmation of whether MediaPlatform binds ports based on ServiceBaseUrl or only from InstanceInternalPort / MediaPortRange

A recommended port layout to avoid collisions

Any Windows-specific gotchas (HTTP.sys reservations, excluded port ranges, etc.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MediaPlatformSettings and CommunicationsClientBuilder setup in Startup.cs, then review MediaPlatformHostedService and the Build() call. Reproduce the failure with the stated Kestrel, internal, public, and media port values, and inspect the SDK's initialization and binding behavior. Done means identifying the conflicting binding or documenting the supported port and ServiceBaseUrl configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.