Skip to content

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

@12144

Description

@12144

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions