Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Javascript Code for Socketio Doesn't Work on C#

The problem is as the title says, I got the Nugget package for Socket.io on C#, then the tried moving same code that I have working on Javascript to it, and it doesn't work on C#. I'm new to WebSockets so I'd appreciate any help.

Here's the Javascript code that works:

const io = require('socket.io-client');

//function
async function initSocket() {
    //define socket
    const socket = io(
        "wss://trade.csgoempire.com/trade", {
            transports: ["websocket"],
            path: "/s/",
            extraHeaders: { 'User-agent': `test API Bot` }
        }
    );
    //connect event
    socket.on('connect', async() => {
        console.log(`Connected to websocket`);
        //log new items
        socket.on('new_item', (data) => console.log(`new_item`));
        socket.on('deleted_item', (data) => console.log(`deleted_item`));
    });
};
//run function
initSocket();

And here's the C# code that doesn't:

//define socket
var SIO = new SocketIO("wss://trade.csgoempire.com/trade/", new SocketIOOptions()
     {
     EIO = 3,
     Transport = SocketIOClient.Transport.TransportProtocol.WebSocket,
     Path = "/s/",
     ExtraHeaders = new Dictionary<string, string> { { "User-agent", "Test API Bot" } }
     });
    
//connect event
SIO.On("connect", async (connectData) =>
     {
     Console.WriteLine("Connected to Websocket");
    
     SIO.On("new_item", (data) => Console.WriteLine("new_item"));
     SIO.On("deleted_item", (data) => Console.WriteLine("deleted_item"));
     });

Moving the whole project to JS is indeed an option but I'm just really frustrated and can't figure out what I'm doin wrong.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!