Skip to content

node sdk can't establish websocket with rust server #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
12144 opened this issue Jan 20, 2025 · 0 comments
Open

node sdk can't establish websocket with rust server #19

12144 opened this issue Jan 20, 2025 · 0 comments

Comments

@12144
Copy link

12144 commented Jan 20, 2025

when i use featureprobe-server-sdk-node, the sdk try to establish websocket with rust server, but establish failed, and continuously report websocket error. i notice the sdk use socketio-client to connect websocket, the corresponding code is

  private async connectSocket() {
    const url = new URL(this._realtimeUrl);

    this._logger?.info('connect socket to ' + this._realtimeUrl + ' ' + url.pathname);
    const socket = io(this._realtimeUrl, { transports: ['websocket'], path: url.pathname });

    socket.on('connect', () => {
      this._logger?.info('connect socketio success');
      socket.emit('register', { key: this._serverSdkKey });
    });

    socket.on('update', () => {
      this._logger?.info('socketio recv update event');
      (async () => {
        await this._toggleSyncer.syncNow()
      })()
    });

    socket.on('connect_error', (error: Error) => {
      this._logger?.info(`socketio error ${error.message}`);
    })

    // this._socket = socket;
  }

but the 'connect' event listener nerver be triggered. i pick this code fragment out to reproduce the bug, and the error happened. i also tried go sdk and it can work well, both js sdk and node sdk can't work, i guess there is something wrong between socketio-client and rust server

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

const { io } = client;

function main() {
  const socket = io("http://localhost:4011/realtime", {
    path: "/realtime",
    transports: ["websocket"],
  });

  socket.on("connect", () => {
    console.log("connected to AB");
  });

  socket.on("connect_error", (error) => {
    console.log(`socketio error ${error}`);
  });
}

main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant