Develop with Refinitiv WebSocket API Docker Image with C# in VS Code Using the Remote - Containers extension
- version: 2.0
- Last update: July 2023
- Environment: Docker
- Compiler: C#
- Prerequisite: Demo prerequisite
Example Code Disclaimer: ALL EXAMPLE CODE IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS FOR ILLUSTRATIVE PURPOSES ONLY. REFINITIV MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF THE EXAMPLE CODE, OR THE INFORMATION, CONTENT, OR MATERIALS USED IN CONNECTION WITH THE EXAMPLE CODE. YOU EXPRESSLY AGREE THAT YOUR USE OF THE EXAMPLE CODE IS AT YOUR SOLE RISK.
Visual Studio Code (or just VS Code) is a free source code editor developed and maintained by Microsoft. This cross-platform editor rapidly gained popularity with developers as it is fast and lightweight, supports a variety of programming languages with IntelliSense (a feature that has originated with VS Code’s older sibling, Visual Studio IDE), and enables complete development operations like debugging, task running, and version control.
VS Code provides numerous extensions that add features and expand development workflows like the remote development that lets developers use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment with the Remote Development Extension Pack.
As part of the Remote Development Extension Pack, the Remote - Containers extension lets developers use a Docker container as an immutable/sandbox development environment. It allows the developers to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set (IntelliSense, code navigation, debugging, etc) as a local-quality development experience. This feature is called devcontainer or dev container.
The previous Article.RTSDK.Java.Cpp.DevContainer project demonstrates how to use Refinitiv Real-Time SDK Java/C++ Docker Images devcontainer with VS Code Remote - Containers extension. This example project shows how to set up a .NET devcontainer with the Remote - Containers extension to for the Refinitiv Real-Time Optimized (RTO) C# WebSocket examples using a Dockerfile. This Dockerfile is built on top of the refinitivapis/websocket_api Docker Image and developers can run the RTO C# WebSocket examples codes directly in VS Code.
Update: The refinitivapis/websocket_api Docker Image has been updated to the current version of WebSocket API GitHub repository. All C# example projects have been update to .NET 6.0.
As part of the Refinitiv Real-Time SDK, the Websocket API for Pricing Streaming and Real-Time Service (aka Websocket API) provides a connection to Refinitiv Real-Time via a standard WebSocket protocol and JSON message format. Developers can use multiple client technology standards such as Python, JavaScript, .Net, etc. to establish WebSocket connections to Refinitiv Real-Time Distribution Systems (RTDS), or Refinitiv Real-Time - Optimized (RTO - cloud solution) available via Refinitiv Data Platform (RDP).
The WebSocket API examples source code for various programming languages is available on GitHub. If developers are new to the Refinitiv Real-Time, they can use the refinitivapis/websocket_api Docker Image to learn the WebSocket API and RTO connection flows quickly. This Docker image contains all WebSocket API Examples, the Python runtime, and dependencies required to run the Python WebSocket examples. You can check my colleague's Introduction to the refinitivapis/websocket_api Docker Image article for step-by-step guidance on how to deploy and run the RTSDK Docker images via the Docker command line.
If you are using the Refinitiv Real-Time SDK C/C++ or Java, there are the following Docker images that contain the latest version SDK too.
- refinitivapis/realtimesdk_c: This docker image contains the latest version of the RTSDK C/C++ libraries and examples.
- refinitivapis/realtimesdk_java: This docker image contains the latest version of the RTSDK Java libraries and examples.
This example requires the following dependencies software and libraries.
- Visual Studio Code editor.
- Docker Desktop/Engine application.
- VS Code - Remote Development extension pack
- Access to the Refinitiv Refinitiv Data Platform and Refinitiv Real-Time - Optimized. (for the RTO example only)
- Internet connection.
I highly recommend following System requirements and Installation sections to set up your environment.
Please contact your Refinitiv representative to help you to access the RTO account and services. You can find more detail regarding the RDP and RTO access credentials set up from the Getting Started for Machine ID section of the Getting Start with Refinitiv Data Platform article.
Please see the full details over the RTO C# devcontainer implementation on the WebSocketAPI_DevContainer.md file.
This example project contains the following files and folders
- .devcontainer/devcontainer.json: An example devcontainer configuration file.
- .devcontainer/Dockerfile: An example Dockerfile.
- .devcontainer/.env.devcontainer.example: An example
.env.devcontainerfile. - .vscode: VS Code debugging configurations for the RTO C# WebSocket example.
- images: Project images folder.
- LICENSE.md: Project's license file.
- README.md: Project's README file.
- WebSocketAPI_DevContainer.md: Project's Document file.
The first step is to unzip or download the example project folder into a directory of your choice, then follow the steps below.
-
Go to the project's .devcontainer folder and create a file name
.env.devcontainerwith the following content.# V1 RTO_USERNAME=<Version 1 RTO Machine-ID> RTO_PASSWORD=<Version 1 RTO Password> RTO_CLIENTID=<Version 1 RTO AppKey> # V2 RTO_CLIENTID=<Version 2 Client-ID> RTO_CLIENTSECRET=<Version 2 Client-Secret>
Please note that the environment variable file above contains the V1 and V2 Authentication. If you have only V1 or V2, please change the file based on your preference.
-
Start a Docker desktop or Docker engine on your machine.
-
Open the project folder in the VS Code editor
-
Install the VS Code - Remote Development extension pack.
-
Open the VS Code Command Palette with the
F1key, and then select the Remote-Containers: Reopen in Container command.
Now VS Code is ready to run the RTO C# WebSocket devcontainer.
Question: I do not have the RTO credentials.
Answer: Please contact your Refinitiv representative to help you to access the RTO account and services.
Question: When I select the Remote-Containers: Reopen in Container command, VS Code returns an error with Docker returned an error. Make Sure the Docker daemon is running. message.
Answer: Please install and start a Docker desktop or Docker engine on your machine.
Question: When I select the Remote-Containers: Reopen in Container command, VS Code returns an error with Docker returned an error. Make Sure the Docker daemon is running. message.
Answer: Please install and start a Docker desktop or Docker engine on your machine.
Question: VS Code throws an error with the An error occurred setting up the container message.
Answer: Please choose the Open devcontainer.json Locally option. Delete Docker container and images (named vsc-XXX), check the error log file, and restart the process.
Question: VS Code throws an error and the log show *docker: open .devcontainer/.env.devcontainer: The system cannot find... message.
Answer: This error message means you do not have a .dev.devcontainer environment variables file in the .devcontainer folder. Please create it using the template from a .dev.devcontainer.example file.
Docker is an open containerization platform for developing, testing, deploying, and running any software application. It helps developers create a consistent development environment (aka devcontainer) without manually maintaining dependencies and toolsets for the project. The VS Code Remote - Containers let developers develop applications with a devcontainer using VS Code full-featured sets such as debugging and various extensions. This devcontainer is easy to set up and share among the project team.
This example project is just a brief introduction to the Remote - Containers extension. Developers can work with Docker Compose to build a customized Docker image that matches the development requirements, debugging, install various VS Code extensions to use in the Dev Container (via the GUI or configuration file), clone Docker container from Git repository, attach the VS Code to a running container, port forwarding, and much more. I highly recommend you check the following VS Code resources for more details:
- Developing inside a Container
- Remote development in Containers tutorial
- Create a development container
- devcontainer.json reference
The refinitivapis/websocket_api Docker Image is a good starting point for developers who are new to the WebSocket API. Developers can use the Docker Image with the Remote - Containers extensions to set up a development environment, and run the Python WebSocket examples. Developers who are using other programming languages can install more compilers/runtime to run the WebSocket examples based on their preferred technology too.
For further details, please review the following resources:
- WebSocket API on the Refinitiv Developer Community website.
- Refinitiv Real-Time & Distribution Family page page.
- Changes to Customer Access and Identity Management: Refinitiv Real-Time - Optimized
- Websocket API Quick Start page.
- Developer Article: 10 important things you need to know before you write an Enterprise Real Time application article.
- Introduction to the refinitivapis/websocket_api Docker Image article.
- Develop with Refinitiv Real-Time SDK Docker Image in VS Code article.
- Introduction to the refinitivapis/realtimesdk_c Docker Image article.
- Introduction to the refinitivapis/realtimesdk_java Docker Image article.
- Coding & Testing Linux Applications on Windows using WSL and VS Code article.
- VS Code: Developing inside a Container page.
- VS Code: Remote development in Containers tutorial page.
- VS Code: Create a development container page.
- VS Code: devcontainer.json reference page.
- VS Code: Create a development container: Dockerfile page.
- VS Code: Debugging and Task Variables reference page.
- VS Code: Remote Development: Environment variables reference page.
- Try Out Development Containers: .NET Core page.
- Docker run reference page.
- Dockerfile reference page.
- Setting up a VS Code Dev Container blog post.
- Hands-On with VSCode & "Dev Containers" blog post.
- Development Acceleration Through VS Code Remote Containers: An Introduction blog post.
- Secure and immutable development environments with Dev Containers blog post.
For any questions related to this project or the WebSocket API page, please use the Developer Community Q&A Forum.




