WebRTC in Hyper-V Windows Server VM

ZIN MIN
6 min readMar 31, 2023

--

Today I want to share my experience resolving a problem I faced with WebRTC application not working on a Microsoft Hyper-V Windows Server VM. I had an application that needed to communicate with an on-premises camera via WebRTC technology, and while testing the application locally was successful, deploying it on an Azure cloud VM posed a problem.

I checked WebRTC from https://webcasts.com/webrtc/.

I devoted several days to resolving this issue, which consumed a significant amount of my time. I am sharing my experience here for those who are encountering a similar problem.

What is the root cause?

After digging deep into the WebRTC and Hyper-V VM, I found that the root cause of the problem was due to resource sharing and Windows Server remote license issue at Hyper-V VM.

How to solve?

In this article, I will share about how to solve “WebRTC application is not working in Hyper-V windows virtual machine issue”. Below are steps we have to do to solve this issue:

  1. Understand about windows remote desktop connection sharing local resource via remote session.
  2. Enabling remote session feature in windows server 2022
  3. Installing remote license manager
  4. Installing windows server remote license CALs
  5. Checking with remote desktop license installation from RD license diagnoser
  6. Starting windows audio service in windows server virtual machine
  7. Allow camera and microphone access to other application in windows settings.
  8. Testing WebRTC feature from https://webcasts.com/webrtc/

Sharing local resources in remote desktop connection

The WebRTC application requires access to the local hardware camera and microphone, but Hyper-V VM does not have a microphone and camera since it is a VM on the cloud. To solve this, the virtual machine system utilizes virtual devices and shares resources from connected clients. When connecting to a Windows VM with a remote desktop connection, we can share local resources to the VM.

To do this, under Remote audio, click “Settings…

Choose the option to use audio playback and recording for the remote computer. Select “Play on this computer” and “Record from this computer” to share the microphone and speaker in the virtual machine.

Next one is under Local devices and resources section, click on “More…” button and tick (select) to share local devices in virtual machine.

Even I select all, problem is still existed. Why?

It could be my technical knowledge problem or carelessly read the information. In the above dialog windows, you can notice that “… you want to use in your remote session.” That is a clue, but I was not clear what does it mean about remote session.

The root cause of the problem was the remote session. To share local resources from the Windows Server remote session, we need to enable it from the Windows Server Roles feature.

How to enable remote session in windows server?

Open Windows server Add Role and Feature wizard from server manager page. Select (tick) “Remote Desktop Services” from roles items.

Under the role services, select (tick) “Remote Desktop Licensing” and “Remote Desktop Session Host”.

Remote desktop session host is a service that create a session for each connection. Therefore, client can share local resources via the remote session.

We still need for Remote Desktop Licensing service because Microsoft is managing with CAL — Client Access License per user or per device. If you did not properly configure the remote desktop license, you will see below warning message. You can skip this part if you don’t have remote desktop license ready.

How to configure Remote Desktop License?

To configure RD license, you must have Microsoft RD License CAL per user or per device.

First, go to RD Licensing Manager (you can type RD in windows search box if you don’t know how to open RD License Manager.), right click on the server's name and click on the “Activate Server” menu.

You can provide your information in Activate Server Wizard. In the last page of the Activate Server Wizard, you can uncheck “Start Install Licenses Wizard now” check box.

RD License Server is activated. Next step is license installation. Expend the server and right click on the server name and click “Install License”.

From the Install License Wizard, choose “License program” type. For my case, I choose “License Pack (Retail Purchase)”.

In the next page, you can provide your license depend on what kind of license type.

Now RD License is successfully installed.

However, mission is not completed. If you go RD Licensing Diagnoser, you can see the error massage that License Mode is not configured.

Open Local Group Policy Editor. Go to

Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Licensing.

You can see there are three settings. You need to configure “Use the Specified Remote Desktop license server” and “Set the Remote Desktop licensing mode” settings.

First double click on the “Use the Specified …..” setting and choose “Enable” option and type license server name.

Next setting is “Enable” remote desktop licensing mode and choose the licensing mode. In my case, licensing mode is Per Device.

Now Remote Desktop license is properly installed and configured. You can check the result from RD License Manager, there is no error or warning.

But mission still not complete. Need to enable windows audio service and allow windows camera and microphone access from privacy setting.

How to start (enable) windows audio service?

This is simple, just go to windows services and start the Windows Audio service.

Last step is “allow camera and microphone access” from windows setting.

How to allow camera and microphone access?

Type “Camera Privacy” keyword in windows search box and enable camera access for other apps from windows setting.

Same way, type “Microphone privacy” keyword in windows search box and enable microphone access for other apps from windows setting.

Mission completed.

Now you can go to https://webcasts.com/webrtc/ and test. WebRTC will request Camera access and Microphone access. Click on the Allow button.

Now WebRTC application is working in Hyper-V windows server VM.

Thanks you.

--

--

Responses (1)