Live Share 的連線需求Connectivity requirements for Live Share

本文摘要說明 Visual Studio Live Share 的連線需求、可用的連線選項,以及適用的已知因應措施。This article summarizes the connectivity requirements for Visual Studio Live Share, available connectivity options, and known workarounds when applicable.

登入Sign in

您可以使用任何Azure Active Directory的受支援工作或學校帳戶、 Microsoft 帳戶GitHub 設定檔來登入 Live Share。You can sign into Live Share using any Azure Active Directory backed work or school account, a Microsoft account, or a GitHub profile. 通常,在大部分組織中,這些的登入 Url 會在指定使用它們的公開產品數目的情況下開放,但如果沒有,請洽詢您的網路系統管理員關於開啟 和/或,以及以下所列的網域。Typically sign-in URLs for these are open in most organizations given the number of public facing products that use them, but if not, contact your network administrator about opening up and/or in addition to the domains listed below.


目前不支援內部內部部署 AD (ADFS)帳戶和內部內部部署 GitHub Enterprise 帳戶(向上投票 👍)On-prem AD (ADFS) accounts and on-prem GitHub Enterprise accounts are not currently supported (up-vote 👍).

連接模式Connection modes

為了確保最佳效能,根據預設,Visual Studio Live Share 會自動偵測共同作業會話主機電腦和來賓電腦是否可以直接透過網路進行通訊,以及只有在兩者之間沒有路由時,才會透過雲端進行轉送。To ensure optimal performance, by default Visual Studio Live Share automatically detects whether a collaboration session host machine and guest machine can communicate directly over a network and only relays via the cloud if there is no route between them. 這種混合的「自動」模式具有彈性,甚至可讓某些來賓透過雲端進行轉送,而其他人則直接連接到相同的會話。This mixed "auto" mode is flexible and even allows some guests to relay through the cloud while others connect directly for the same session.

直接連線是透過以雲端為基礎的機制進行驗證,以確保安全性,但需要在5990和5999之間開啟一個埠,才能啟用連線能力。The direct connections are authenticated via a cloud based mechanism to ensure security but require a port between 5990 and 5999 be opened to enable the connectivity. 因此,當您第一次共用桌面防火牆時,可能會提示您開啟埠。As a result, when sharing for the first time your desktop firewall may prompt you open a port. 接受這是選擇性的,因為忽略它只會導致 Live Share 在 auto 模式中一律使用轉送。Accepting this is optional as ignoring it will simply cause Live Share to always use the relay when in auto mode.

Visual Studio Live Share 中的所有連線都是透過 SSH 或 SSL 加密,並針對中央服務進行驗證,以確保只有共同作業會話中的連線可以存取其內容。All connections in Visual Studio Live Share are SSH or SSL encrypted and authenticated against a central service to ensure that only those in the collaboration session can gain access to its content. 此外,Live Share 的雲端轉送不會保存任何透過它路由傳送的流量,也不會以任何方式「窺探」流量。In addition, Live Share's cloud relay does not persist any traffic routed through it and does not "snoop" the traffic in any way.

變更連接模式Changing the connection mode

如果您想要停用直接或轉送連線,或只是針對連線問題進行疑難排解,您可以強制執行其他連接模式。If you would prefer to disable direct or relayed connections or are simply troubleshooting connectivity problems, you can force other connection modes.

模式Mode 主機行為Host Behavior 來賓行為Guest Behavior
AutoAuto 主機的共同作業會話會接受安全、已驗證的直接連線或雲端轉送連線。The host's collaboration session accepts secured, authenticated direct connections or cloud relayed connections. 嘗試使用直接連線,並在失敗時透過雲端回復至轉送。Attempts to use a direct connection and falls back to relaying through the cloud if this fails.
直接Direct 主機的共同作業會話只接受已驗證、安全的直接連接。The host's collaboration session only accepts authenticated, secure direct connections. 嘗試使用直接連線,並在無法連接時停止。Attempts to use a direct connection and stops if it cannot connect.
RelayRelay 主機的共同作業會話不允許直接連接。The host's collaboration session does not allow direct connections. 未在主機的電腦上開啟任何埠。No port is opened on the host's machine. 一律透過雲端連接。Always connects via the cloud.

若要變更模式:To change the mode:


  1. 移至 工具 > 選項 > Live Share。Go to Tools > Options > Live Share.
  2. 從 [連接模式] 下拉式清單中選取 [模式]。Select the mode from the "Connection Mode" dropdown.
  3. 重新開機與Restart VS.

VS Code:VS Code:

  1. 編輯設定. json (檔案 > 喜好設定 > 設定)。Edit settings.json (File > Preferences > Settings).
  2. 根據您的喜好設定,將 "liveshare.connectionMode" 設為 "auto""direct""relay"Set "liveshare.connectionMode" to "auto", "direct", or "relay" depending on your preference.
  3. 重新開機 VS Code。Restart VS Code.

連接模式的需求Requirements for connection modes

您所在的連線模式將會指定需要提供給 Live Share 運作的特定埠和 Url。The connection mode you are in will dictate the specific ports and URLs that need to be available for Live Share to function.

模式Mode 用戶端存取需求Client Access Requirement 疑難排解Troubleshooting
AnyAny * 的輸出存取Outbound access to * 確定您的公司或個人網路防火牆可讓您連線到此網域。Ensure your corporate or personal network firewall allows you to connect to this domain. 在瀏覽器中輸入 ,並確認您居住在 Visual Studio Live Share 首頁。Enter in a browser and verify you land at the Visual Studio Live Share home page. 您也可能會遇到需要解決的proxy 問題You may also be running into proxy issues that need to be resolved.
任何(VS Code)Any (VS Code) 的輸出存取Outbound access to 確定您的公司或個人網路防火牆可讓您連線到此網域。Ensure your corporate or personal network firewall allows you to connect to this domain. 您也可能會遇到需要解決的proxy 問題You may also be running into proxy issues that need to be resolved.
AutoAuto 自動切換。Auto-switches. 請參閱 direct 和轉送模式。See direct and relay modes. 切換至直接或轉送模式進行疑難排解。Switch to direct or relay mode to troubleshoot.
直接Direct 主機:在 5990-5999 範圍中的埠必須開啟,才能接受傳入的局域網路連接。Hosts: A port in the range 5990 - 5999 needs to be opened to accept inbound local network connections.

來賓:此相同埠上主機的網路路由和輸出存取。Guests: A network route and outbound access to the host on this same port.
請確認此埠範圍的桌面防火牆軟體未封鎖「.vsls.json 代理程式」,而且您可以彼此 ping。Verify "vsls-agent" is not blocked by your desktop firewall software for this port range and that you can ping one another. 雖然 Windows 和其他桌面軟體應該會在代理程式第一次啟動時提示您,但我們也看到群組原則防止這種情況發生的情況,因此您必須手動新增專案While Windows and other desktop software should prompt you the first time the agent starts up, we have seen instances where group policies prevent this from happening and you will need to manually add the entry. 您也可能會遇到需要解決的proxy 問題You may also be running into proxy issues that need to be resolved.
RelayRelay *的輸出存取。Outbound access to * 確定您的公司或個人網路防火牆可讓您連線到此網域。Ensure your corporate or personal network firewall allows you to connect to this domain. 您也可能會遇到需要解決的proxy 問題You may also be running into proxy issues that need to be resolved.

手動新增防火牆專案Manually adding a firewall entry

如上面所述,直接模式需要您的個人防火牆允許 .vsls.json 代理程式接受埠範圍5990-5999 中的連接。As outlined above, direct mode requires that your personal firewall allow vsls-agent to accept connections in the port range 5990-5999. 如果您想要使用直接模式,但發現您的防火牆沒有 .vsls.json 代理程式專案,您可以手動將它新增。If you want to use direct mode but have found that your firewall does not have vsls-agent entry, you can add it manually. 執行此動作的方式會因防火牆軟體而異,但是您可以在 這裡找到設定 Windows 防火牆的 相關資訊。How you do this will vary by firewall software, but you can find information about configuring the Windows Firewall here.

如果您看不到 .vsls.json 代理程式的專案,您可以在下列其中一個位置找到代理程式可執行檔。If you do not see an entry for vsls-agent, you can find the agent executable in one of the following locations.

VS Code 代理程式位置VS Code agent location

以下列其中一個路徑中的延伸模組版本號碼取代版本Substitute VERSION for the extension version number in one of the paths below:

  • macOS,LinuxmacOS, Linux


  • WindowsWindows


Visual Studio 代理程式位置Visual Studio agent location

Visual Studio 位置是動態的,但您可以依照下列步驟來尋找可執行檔:The Visual Studio location is more dynamic, but you can follow these steps to find the executable:

  1. 流覽至您的 Visual Studio 安裝位置。Navigate to your Visual Studio install location. 這通常是 C:\Program Files (x86)\Microsoft Visual Studio\EDITION版本是「社區」、「企業」等等This is typically C:\Program Files (x86)\Microsoft Visual Studio\EDITION where EDITION is Community, Enterprise, etc

  2. IDE\Extensions子資料夾下執行搜尋 vsls-agent.exeRun a search for vsls-agent.exe in under the IDE\Extensions sub-folder.

可惜的是,您可能需要在每次更新 Visual Studio Live Share 時執行此步驟。Unfortunately you may need to do this step each time you update Visual Studio Live Share.


Visual Studio Live Share 目前在 proxy 使用方面有一些限制。Visual Studio Live Share currently has some limitations around proxy use. 雖然自動 proxy 設定應可在 Windows 上正常執行,但在使用 macOS 或 Linux 時(以及 Windows 上的特定 proxy 設定), HTTP_PROXYHTTPS_PROXY環境變數將需要全域設定。While automatic proxy settings should work on Windows, when using macOS or Linux (and with certain proxy configurations on Windows) the HTTP_PROXY and HTTPS_PROXY environment variables will need to be set globally.

如果您的 proxy 不會自動為您設定這些,您可以手動設定下列格式的變數:If your proxy doesn't automatically set these for you, you can manually set the variables in the following form:


如果您有驗證 proxy,您可以新增使用者和密碼,如下所示:If you have an authenticating proxy, you can add your user and password as follows:


如果這些設定無法為您解決問題,請讓我們知道您 proxy 設定的細節,讓我們可以查看如何改進支援。If these settings don't solve the problem for you, please let us know the specifics of your proxy setup so we can take a look at improving support.

請參閱See also

有問題嗎?Having problems? 請參閱疑難排解提供意見反應See troubleshooting or provide feedback.