Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda