React Native / SignalR - can't use websocket url : Error: Cannot resolve 'wss://http://xxxx.yyy.net/ws'

Viewed 31

I try to connect SignalR and React Native with websocket. I get this error:

Error: Cannot resolve 'wss://http://xxxx.yyy.net/ws'.

Here is my code:

  constructor(props) {
    super(props);

    this.state = {
      message: "No messages.",
    };

    this.messageReceived = this.messageReceived.bind(this);

    const hubUrl = 'wss://http://xxxx.yyy.net/ws';

    const connectionHub = new signalR.HubConnectionBuilder()
      .withUrl(hubUrl)
      .configureLogging(signalR.LogLevel.Information)
      .build();

    connectionHub.on("ReceiveMessage", this.messageReceived);
    connectionHub.start().catch((err) => this.logError(err));

    this.connection = connectionHub;
  }

0 Answers
Related