Skip to content

PiggyCrash/vision_dotnet_websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# WebSocket Deployment on Linux (WSL/Ubuntu)

This project demonstrates a simple yet robust WebSocket server and client implementation using .NET.

Projects

  • Server: ASP.NET Core Minimal API handling WebSocket connections at /ws.
  • Client: Console application for interacting with the server.

Data Process Flow

Overall Flow: Client ➔ TCP Handshake ➔ HTTP Upgrade Request ➔ Server ➔ 101 Switching Protocols ➔ WebSocket Established ➔ Data Exchange

Production Configuration

Add the following to your Nginx site configuration (/etc/nginx/sites-available/default):

server {
    listen 80;
    server_name example.com;

    location /ws {
        proxy_pass http://localhost:5000/ws;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        
        # Timeout settings for long-lived connections
        proxy_read_timeout 86400s;
        proxy_send_timeout 86400s;
    }
}

Running the Application

In WSL:

# 1. Start the Server
cd Server
dotnet run

# 2. (In another WSL terminal) Start the Client
cd Client
dotnet run

About

This project demonstrates a simple yet robust WebSocket server and client implementation using .NET.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages