I keep getting Failed to start the transport 'WebSockets': null when connecting to server.
I'm implementing a simple chat in reactnative mobile app. And I'm using @aspnet/signalr(version-1.1.4) library. I am getting this error - Error: Failed to start the transport 'WebSockets': null. See logs here
componentDidMount(){
try {
const connection = new signalR.HubConnectionBuilder() //Connect to a hub
.withUrl(baseUrl + `/chatbus`, {
transport: signalR.HttpTransportType.WebSockets | signalR.HttpTransportType.LongPolling,
'content-type': 'application/json',
accessTokenFactory: () => authToken //for authorization
})
.configureLogging(signalR.LogLevel.Debug)
.build();
connection.on('NotifySignalR', (ChatObject) => {
console.log(ChatObject);
});
connection.start()
.then(() => {
console.log('Chat Connection started.');
console.log('Now connected, connection ID=' + connection.id);
this.initalAttemptForChat = true;
connection.invoke("start");
})
.catch(() => {
this.initalAttemptForChat = false;
console.log('Error while establishing chatbus connection!');
});
} catch (e) {
console.log("error ", e);
throw e;
}
}
If you have you app in Windows Server just enable thw "WebSocket Protocol".
"Add or Remove Programs">"Turn Windows features on or off" > "Web Server(IIS)">"Web Server">"Application Development">"WebSocket Protocol".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With