microsoftgraph / microsoft-graph-comms-samples

Microsoft Graph Communications Samples
MIT License
204 stars 220 forks source link

Screen Share on VMSS hosted Azure VM #727

Closed ebade closed 1 week ago

ebade commented 1 month ago

I am attempting to setup a sandbox for a program I am writing based heavily on the PSI Ball Bot. I was able to setup the application locally using NGROK successfully. I am mainly a C# developer and am having trouble with understanding that all of the VM server components are running successfully.

This is being hosts on a VMSS in Azure as a Windows 10 deployment.

So far I have setup the code and all the ports to forward and the bot can join my meeting. However I know that the screen share status is depending on getting updates on the '/api/calling' endpoint. I have put in lot of console outputs to see where the code is being trigger and notice that none of the usual updates to the call via the '/api/calling' and being called. I am able to tell the bot to join the call with the '/joincall' endpoint and I am able to get to call logs (I did once with just a bunch of not getting audio from participant messages) so at least he logs endpoint is working as well.

On the server my config options are as follows (changed some information for security): "ConfigOptions": { "AllowedHosts": "*", "BOT_NAME": "Bot Name", "BOT_ID": "", "BOT_PASSWORD": "", "SERVICE_CNAME": ":5001", "MEDIA_SERVICE_FQDN": "", "SERVICE_DNS_NAME": "", "CERTIFICATE_THUMBPRINT": "", "INSTANCE_PUBLIC_PORT": 8445, "CALL_SIGNALING_PORT": 5001, "INSTANCE_INTERNAL_PORT": 8445, "PLACE_CALL_ENDPOINT_URL": "https://graph.microsoft.com/v1.0", "PSI_STORE_DIRECTORY": "" }

I also am setting the server urls in the appsettings.json with: "urls": "https://0.0.0.0:5001;http://0.0.0.0:5000"

The thumb print for the certificate was generated using the certbot as well as openssl to create the windows version of the key.

I have read countless posts in these forums related to how to get all of this working and I feel like I am missing a simple step. I have created the certificate on the server (which I know people said not to do) as a local signed cert with dotnet dev-certs https --trust which at least gets the server started and I thought just the media portion need the thumbprint of the actual certificate.

Like I said, everything is working from connection to joining the meeting with the bot, I am even getting console logs that audio and video are connected, just the updates that would trigger the screen share are not currently firing to get the last piece connected.

ssulzer commented 1 month ago

@ebade Can you please share a callChainId of a call session where screen sharing is not working? Is your bot trying to become a screen sharer? Thanks.

ebade commented 1 month ago

Call ID: 7b1f6300-2f70-47c3-af58-b782fe308e01 Yes, I am attempting to perform screen share from the bot. The goal is to the have the bot join the room and kick up screen share like the PSI bot demo.

Using Ngrokon the server did help get screen sharing working, however I am looking for a solution to not have to run Ngrok in the production environment. With Ngrok working I assume, in my current setup and just running the app, it is the API calls not having a valid certificate to the server. I have list below what I am using in my program.cs to startup the server. It seems like most of the my controllers only have http not https access, which means it is not being hosted as a valid SSL web server. I am more than a little green in terms of hosting production asp net core applications in production. Most of my work lately has been in Azure functions and static web apps. Any advice would be appreciated.

`var builder = WebApplication.CreateBuilder(args);

if !DEBUG

var clientCertificate = new X509Certificate2("", "");

endif

builder.Services.AddControllers(); builder.Services.AddHttpClient("WebClient", client => client.Timeout = TimeSpan.FromSeconds(600))

if !DEBUG

.ConfigurePrimaryHttpMessageHandler(() =>
    {
        Console.WriteLine("Setup Security Settings");
        var handler = new HttpClientHandler();
        handler.SslProtocols = SslProtocols.Tls12;
        handler.ClientCertificates.Add(clientCertificate);
        return handler;
    })

endif

;

builder.Services.AddHttpsRedirection(options => options.HttpsPort = 5001); builder.Services.AddHttpContextAccessor();

// Create the Bot Framework Authentication to be used with the Bot Adapter. /var config = builder.Configuration.Get(); builder.Configuration["MicrosoftAppType"] = "MultiTenant"; builder.Configuration["MicrosoftAppId"] = config.BOT_ID; builder.Configuration["MicrosoftAppPassword"] = config.BOT_PASSWORD; builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFrameworkAuthentication>();/

builder.Services.AddSingleton<IGraphLogger, GraphLogger>(_ => new GraphLogger("MyBot", redirectToTrace: true)); builder.Services.AddSingleton<InMemoryObserver, InMemoryObserver>(); builder.Services.Configure(builder.Configuration.GetSection(nameof(ConfigOptions))); builder.Services.PostConfigure(config => config.Initialize()); builder.Services.AddSingleton<IBotService, BotService>(provider => { var bot = new BotService( provider.GetRequiredService(), provider.GetRequiredService<IOptions>()); bot.Initialize(); return bot; });

var app = builder.Build();

if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseStaticFiles();

app.UseRouting(); app.UseHttpsRedirection(); //app.UseAuthentication(); app.UseAuthorization();

app.MapControllers(); /app.UseEndpoints(endpoints => { endpoints.MapControllers(); });/ app.Run();`

1fabi0 commented 2 weeks ago

You can run the sample without Ngrok in production, Samples in this Repos also include a Azure Kubernetes Service deployment Sample. Also checkout this documentation it's a tutorial to deploy a undeprecated version of the AKS Sample. So it is possible to create a production environment withou Ngrok, you can also try to run the application as an Azure Container Instance in production. Or just plain on the VMSS and modify network rules to allow ingoing traffic to the VMs on HTTPS and TCP/MEDIA ports.

ebade commented 1 week ago

Thank you @1fabi0 I will read through the documentation. I have the app currently in a VMSS and modified all the network ports. It seems the issue is that in the code some of the API endpoints are hosted as HTTP, not HTTPS which is an issue I was trying to resolve. I did make the slight modification with how it launches the app in the above code sample, and that is different than how the psi bot runs the web server, but I did not think that the controllers would bind to different ports.

ebade commented 1 week ago

I finally got my server to work and share without using ngrok. I had to make a change to the way the application was setup in the builder. I basically replaced:

builder.Services.AddHttpClient("WebClient", client => client.Timeout = TimeSpan.FromSeconds(600))

with this section:

'builder.WebHost.UseKestrel(serverOptions => { serverOptions.ListenAnyIP(5000); serverOptions.ListenAnyIP(5001, config => config.UseHttps(settings.DefaultCertificate)); });'